Package org.apache.groovy.contracts.util
Class AnnotationUtils
java.lang.Object
org.apache.groovy.contracts.util.AnnotationUtils
Helper methods for reading/getting AnnotationNode instances.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic List<AnnotationNode>Gets the nextAnnotationNodeinstance in the inheritance line which is annotated with the given Annotation class anno.static List<AnnotationNode>getAnnotationNodeInHierarchyWithMetaAnnotation(ClassNode type, MethodNode originMethodNode, ClassNode metaAnnotationClassNode) Checks whether there exists aMethodNodeup the inheritance tree where exists an annotation which is annotated with metaAnnotationClassNode.static booleanhasAnnotationOfType(AnnotatedNode annotatedNode, String typeOrPackageName) Checks whether the givenClassNodeis annotated with an annotations of the given package or full annotatedNode name.static List<AnnotationNode>hasMetaAnnotations(AnnotatedNode annotatedNode, String metaAnnotationClassName) Loads all annotation nodes of the givenAnnotatedNodeinstance which are marked with the annotation metaAnnotationClassName.
-
Constructor Details
-
AnnotationUtils
public AnnotationUtils()
-
-
Method Details
-
hasAnnotationOfType
Checks whether the givenClassNodeis annotated with an annotations of the given package or full annotatedNode name.- Parameters:
annotatedNode- theAnnotatedNodeto search for the given annotationtypeOrPackageName- can either be a part of the package or the complete annotation class name- Returns:
- true if an annotation was found, false otherwise
-
getAnnotationNodeInHierarchyWithMetaAnnotation
public static List<AnnotationNode> getAnnotationNodeInHierarchyWithMetaAnnotation(ClassNode type, ClassNode anno) Gets the nextAnnotationNodeinstance in the inheritance line which is annotated with the given Annotation class anno.- Parameters:
type- theClassNodeto check for the annotationanno- the annotation to watch out for- Returns:
- the next
AnnotationNodein the inheritance line, or null
-
getAnnotationNodeInHierarchyWithMetaAnnotation
public static List<AnnotationNode> getAnnotationNodeInHierarchyWithMetaAnnotation(ClassNode type, MethodNode originMethodNode, ClassNode metaAnnotationClassNode) Checks whether there exists a
MethodNodeup the inheritance tree where exists an annotation which is annotated with metaAnnotationClassNode.- Parameters:
type- the originClassNodeoriginMethodNode- the originMethodNodemetaAnnotationClassNode- theClassNodeof the meta-annotation- Returns:
- a list of
AnnotationNodeall annotated with metaAnnotationClassNode
-
hasMetaAnnotations
public static List<AnnotationNode> hasMetaAnnotations(AnnotatedNode annotatedNode, String metaAnnotationClassName) Loads all annotation nodes of the givenAnnotatedNodeinstance which are marked with the annotation metaAnnotationClassName.- Parameters:
annotatedNode- anAnnotatedNodefrom which the annotations are checkedmetaAnnotationClassName- the name of the meta annotation- Returns:
- a list of
AnnotationNodeinstances which implement the given metaAnnotationClass
-