Class AnnotationMatcher

java.lang.Object
org.openrewrite.java.AnnotationMatcher

public class AnnotationMatcher extends Object
This matcher will find all annotations matching the annotation pattern

The annotation pattern, expressed as a method pattern, is used to find matching annotations. The format of the expression is as follows:

@#annotationClass#(#parameterName#=#parameterValue#, #parameterName#=#parameterValue#...)

  • The annotationClass must be fully qualified.
  • The parameter name/value pairs can be in any order
  •  EXAMPLES:
     

    @java.lang.SuppressWarnings - Matches java.lang.SuppressWarnings with no parameters. @myhttp.Get(serviceName="payments", path="recentPayments") - Matches references to myhttp.Get where the parameters are also matched. @myhttp.Get(path="recentPayments", serviceName="payments") - Exactly the same results from the previous example, order of parameters does not matter. @java.lang.SuppressWarnings("deprecation") - Matches java.langSuppressWarning with a single parameter. @org.junit.runner.RunWith(org.junit.runners.JUnit4.class) - Matches JUnit4's @RunWith(JUnit4.class)

    • Constructor Details

      • AnnotationMatcher

        public AnnotationMatcher(String signature, @Nullable @Nullable Boolean matchesMetaAnnotations)
      • AnnotationMatcher

        public AnnotationMatcher(String signature)
    • Method Details

      • matches

        public boolean matches(org.openrewrite.java.tree.J.Annotation annotation)
      • matchesAnnotationOrMetaAnnotation

        public boolean matchesAnnotationOrMetaAnnotation(@Nullable JavaType.FullyQualified fqn)