Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add entry point onlyClasses and similar #1196

Open
rweisleder opened this issue Nov 16, 2023 · 0 comments
Open

Add entry point onlyClasses and similar #1196

rweisleder opened this issue Nov 16, 2023 · 0 comments

Comments

@rweisleder
Copy link
Contributor

Because of a recent discussion, I extract my suggestion from this comment into a separate issue.

It would be great to have onlyClasses() as entry point. Rules created with onlyClasses() should fail

  1. if classes that match the that condition, don't match the should condition, and
  2. if classes that don't match the that condition, match the should condition.

Same goes for onlyMethods(), onlyFields(), only(ClassesTransformer) etc.

The current alternative is to write rules "twice":

CompositeArchRule.of(
	classes().that().areAnnotatedWith(RestController.class).should().haveSimpleNameEndingWith("RestController")
).and(
	classes().that().haveSimpleNameEndingWith("RestController").should().beAnnotatedWith(RestController.class)
).as("only classes that are annotated with @RestController should have simple name ending with 'RestController'")

// vs.

onlyClasses().that().areAnnotatedWith(RestController.class).should().haveSimpleNameEndingWith("RestController")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant