classes implement should respect interface extends

Open
#1,482 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
java
Domain
testing

Research direction

Start by reading the examples in the issue and the ArchUnit APIs for classes(), implement(), and haveSimpleNameEndingWith(). The request combines interface matching, composed-annotation detection, and a new reflexive rule API, without choosing a specific scope or expected behavior; clarify which capability should be addressed before estimating completion.

Written by the indexing model from the issue text.

Description

I have

@Value.Immutable
@ValueObject
public interface MyId extends Identifier {
}

and I want to validate

classes().that().implement(Identifier.class).should().haveSimpleNameEndingWith("Id")

even if we agree this is not the right code, I don't see any way to validate the interface. Given I'm using the immutables library, this seems the correct placing.

Additionally, I tried creating an @ImmutableValueObject and annotate it with @ValueObject using immutables @InjectAnnotation and it seems there isn't any way to validate that the annotation exists if it's a composed annotation.

lastly it'd be nice to be able to say something here like

classes().that().implement(Identifier.class).should().haveSimpleNameEndingWith("Id").reflexively()

which would imply

classes().that().implement(Identifier.class).should().haveSimpleNameEndingWith("Id")
classes().that().haveSimpleNameEndingWith("Id").should().implement(Identifier.class)
Dominant language
Java
Stars
3.9k
Forks
350
Avg merge
1d 12h
Merged PRs (30d)
13

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from TNG/ArchUnit

All issues in TNG/ArchUnit

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.