Package org.openrewrite.java.service
Class AnnotationService
java.lang.Object
org.openrewrite.java.service.AnnotationService
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionannotatedWith(org.openrewrite.java.tree.J j, String annotationFqn) Finds all instances of the specified annotation in the type hierarchy, including direct annotations, inherited annotations, and meta-annotations.annotatedWith(org.openrewrite.java.tree.J j, String annotationFqn, boolean includeMetaAnnotations) Finds all instances of the specified annotation in the type hierarchy, including direct annotations, inherited annotations, and optionally meta-annotations.List<org.openrewrite.java.tree.J.Annotation> getAllAnnotations(org.openrewrite.Cursor cursor) booleanisAnnotatedWith(org.openrewrite.java.tree.J j, String annotationFqn) Checks if the given element has the specified annotation, searching through type information including: - Direct annotations on the element - Inherited annotations from parent classes (for class declarations) - Inherited annotations from overridden methods (for method declarations) - Meta-annotations (annotations on annotations)booleanisAnnotatedWith(org.openrewrite.java.tree.J j, String annotationFqn, boolean includeMetaAnnotations) Checks if the given element has the specified annotation, searching through type information including: - Direct annotations on the element - Inherited annotations from parent classes (for class declarations) - Inherited annotations from overridden methods (for method declarations) - Optionally, meta-annotations (annotations on annotations)booleanmatches(org.openrewrite.Cursor cursor, AnnotationMatcher matcher)
-
Constructor Details
-
AnnotationService
public AnnotationService()
-
-
Method Details
-
matches
-
getAllAnnotations
public List<org.openrewrite.java.tree.J.Annotation> getAllAnnotations(org.openrewrite.Cursor cursor) -
isAnnotatedWith
Checks if the given element has the specified annotation, searching through type information including: - Direct annotations on the element - Inherited annotations from parent classes (for class declarations) - Inherited annotations from overridden methods (for method declarations) - Meta-annotations (annotations on annotations)- Parameters:
j- The element to check (J.ClassDeclaration, J.MethodDeclaration, or J.VariableDeclarations)annotationFqn- The fully qualified name of the annotation to search for- Returns:
- true if the annotation is found anywhere in the hierarchy, false otherwise
-
isAnnotatedWith
public boolean isAnnotatedWith(org.openrewrite.java.tree.J j, String annotationFqn, boolean includeMetaAnnotations) Checks if the given element has the specified annotation, searching through type information including: - Direct annotations on the element - Inherited annotations from parent classes (for class declarations) - Inherited annotations from overridden methods (for method declarations) - Optionally, meta-annotations (annotations on annotations)- Parameters:
j- The element to check (J.ClassDeclaration, J.MethodDeclaration, or J.VariableDeclarations)annotationFqn- The fully qualified name of the annotation to search forincludeMetaAnnotations- Whether to search for meta-annotations (annotations on annotations)- Returns:
- true if the annotation is found anywhere in the hierarchy, false otherwise
-
annotatedWith
public List<JavaType.FullyQualified> annotatedWith(org.openrewrite.java.tree.J j, String annotationFqn) Finds all instances of the specified annotation in the type hierarchy, including direct annotations, inherited annotations, and meta-annotations.- Parameters:
j- The element to check (J.ClassDeclaration, J.MethodDeclaration, or J.VariableDeclarations)annotationFqn- The fully qualified name of the annotation to search for- Returns:
- A list of all matching annotations found in the hierarchy
-
annotatedWith
public List<JavaType.FullyQualified> annotatedWith(org.openrewrite.java.tree.J j, String annotationFqn, boolean includeMetaAnnotations) Finds all instances of the specified annotation in the type hierarchy, including direct annotations, inherited annotations, and optionally meta-annotations.- Parameters:
j- The element to check (J.ClassDeclaration, J.MethodDeclaration, or J.VariableDeclarations)annotationFqn- The fully qualified name of the annotation to search forincludeMetaAnnotations- Whether to search for meta-annotations (annotations on annotations)- Returns:
- A list of all matching annotations found in the hierarchy
-