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
-
Method Summary
Modifier and TypeMethodDescriptionstatic List<AnnotationNode>
Gets the nextAnnotationNode
instance 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 aMethodNode
up the inheritance tree where exists an annotation which is annotated with metaAnnotationClassNode.static boolean
hasAnnotationOfType
(AnnotatedNode annotatedNode, String typeOrPackageName) Checks whether the givenClassNode
is 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 givenAnnotatedNode
instance which are marked with the annotation metaAnnotationClassName.
-
Constructor Details
-
AnnotationUtils
public AnnotationUtils()
-
-
Method Details
-
hasAnnotationOfType
Checks whether the givenClassNode
is annotated with an annotations of the given package or full annotatedNode name.- Parameters:
annotatedNode
- theAnnotatedNode
to 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 nextAnnotationNode
instance in the inheritance line which is annotated with the given Annotation class anno.- Parameters:
type
- theClassNode
to check for the annotationanno
- the annotation to watch out for- Returns:
- the next
AnnotationNode
in the inheritance line, or null
-
getAnnotationNodeInHierarchyWithMetaAnnotation
public static List<AnnotationNode> getAnnotationNodeInHierarchyWithMetaAnnotation(ClassNode type, MethodNode originMethodNode, ClassNode metaAnnotationClassNode) Checks whether there exists a
MethodNode
up the inheritance tree where exists an annotation which is annotated with metaAnnotationClassNode.- Parameters:
type
- the originClassNode
originMethodNode
- the originMethodNode
metaAnnotationClassNode
- theClassNode
of the meta-annotation- Returns:
- a list of
AnnotationNode
all annotated with metaAnnotationClassNode
-
hasMetaAnnotations
public static List<AnnotationNode> hasMetaAnnotations(AnnotatedNode annotatedNode, String metaAnnotationClassName) Loads all annotation nodes of the givenAnnotatedNode
instance which are marked with the annotation metaAnnotationClassName.- Parameters:
annotatedNode
- anAnnotatedNode
from which the annotations are checkedmetaAnnotationClassName
- the name of the meta annotation- Returns:
- a list of
AnnotationNode
instances which implement the given metaAnnotationClass
-