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<org.codehaus.groovy.ast.AnnotationNode>getAnnotationNodeInHierarchyWithMetaAnnotation(org.codehaus.groovy.ast.ClassNode type, org.codehaus.groovy.ast.ClassNode anno) Gets the nextAnnotationNodeinstance in the inheritance line which is annotated with the given Annotation class anno.static List<org.codehaus.groovy.ast.AnnotationNode>getAnnotationNodeInHierarchyWithMetaAnnotation(org.codehaus.groovy.ast.ClassNode type, org.codehaus.groovy.ast.MethodNode originMethodNode, org.codehaus.groovy.ast.ClassNode metaAnnotationClassNode) Checks whether there exists aMethodNodeup the inheritance tree where exists an annotation which is annotated with metaAnnotationClassNode.static booleanhasAnnotationOfType(org.codehaus.groovy.ast.AnnotatedNode annotatedNode, String typeOrPackageName) Checks whether the givenClassNodeis annotated with an annotations of the given package or full annotatedNode name.static List<org.codehaus.groovy.ast.AnnotationNode>hasMetaAnnotations(org.codehaus.groovy.ast.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
public static boolean hasAnnotationOfType(org.codehaus.groovy.ast.AnnotatedNode annotatedNode, String typeOrPackageName) 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<org.codehaus.groovy.ast.AnnotationNode> getAnnotationNodeInHierarchyWithMetaAnnotation(org.codehaus.groovy.ast.ClassNode type, org.codehaus.groovy.ast.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<org.codehaus.groovy.ast.AnnotationNode> getAnnotationNodeInHierarchyWithMetaAnnotation(org.codehaus.groovy.ast.ClassNode type, org.codehaus.groovy.ast.MethodNode originMethodNode, org.codehaus.groovy.ast.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<org.codehaus.groovy.ast.AnnotationNode> hasMetaAnnotations(org.codehaus.groovy.ast.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
-