Skip to content
Discussion options

You must be logged in to vote

You can implement a custom predicate:

static imports
import static com.tngtech.archunit.base.DescribedPredicate.describe;
import static com.tngtech.archunit.lang.conditions.ArchPredicates.have;
    ArchRule rule = methods()
            .that().areDeclaredInClassesThat().areAnnotatedWith(Controller.class)
            .and().arePublic()
            .and(have(describe("at least one String parameter", method ->
                    method.getRawParameterTypes().stream().anyMatch(parameter -> parameter.isEquivalentTo(String.class))
            )))
            .should().beAnnotatedWith(PreAuthorize.class);

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by jbader-berner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants