@CompileStatic class AstAnnotationUtils extends Object
Utility methods for dealing with annotations in AST transforms
| Constructor and description |
|---|
AstAnnotationUtils() |
| Type Params | Return Type | Name and description |
|---|---|---|
|
static void |
addAnnotationIfNecessary(AnnotatedNode classNode, Class<? extends Annotation> annotationClass)Adds an annotation to the give class node if it doesn't already exist |
|
static AnnotationNode |
addAnnotationOrGetExisting(AnnotatedNode classNode, Class<? extends Annotation> annotationClass)Adds an annotation to the given class node or returns the existing annotation |
|
static AnnotationNode |
addAnnotationOrGetExisting(AnnotatedNode annotatedNode, Class<? extends Annotation> annotationClass, Map<String, Object> members)Adds an annotation to the given class node or returns the existing annotation |
|
static AnnotationNode |
addAnnotationOrGetExisting(AnnotatedNode annotatedNode, ClassNode annotationClassNode) |
|
static AnnotationNode |
addAnnotationOrGetExisting(AnnotatedNode annotatedNode, ClassNode annotationClassNode, Map<String, Object> members) |
|
static AnnotationNode |
findAnnotation(AnnotatedNode classNode, Class<?> type) |
|
static AnnotationNode |
findAnnotation(AnnotatedNode annotationClassNode, List<AnnotationNode> annotations) |
|
static boolean |
hasAnnotation(MethodNode methodNode, Class<? extends Annotation> annotationClass)Returns true if MethodNode is marked with annotationClass |
|
static boolean |
hasAnnotation(MethodNode methodNode, ClassNode annotationClassNode) |
|
static boolean |
hasAnnotation(MethodNode methodNode, String annotationClassName)Returns true if MethodNode is marked with annotationClass |
|
static boolean |
hasAnnotation(List<AnnotationNode> annotationNodes, AnnotationNode annotationNode) |
|
static boolean |
hasAnnotation(ClassNode classNode, Class<? extends Annotation> annotationClass)Returns true if classNode is marked with annotationClass |
|
static boolean |
hasAnyAnnotations(ClassNode classNode, Class<? extends Annotation>[] annotationsToLookFor)
|
|
static boolean |
hasJunitAnnotation(MethodNode md)Whether the method node has any JUnit annotations |
Adds an annotation to the give class node if it doesn't already exist
classNode - The class nodeannotationClass - The annotation classAdds an annotation to the given class node or returns the existing annotation
classNode - The class nodeannotationClass - The annotation classAdds an annotation to the given class node or returns the existing annotation
annotatedNode - The class nodeannotationClass - The annotation classReturns true if MethodNode is marked with annotationClass
methodNode - A MethodNode to inspectannotationClass - an annotation to look forReturns true if MethodNode is marked with annotationClass
methodNode - A MethodNode to inspectannotationClass - an annotation to look forReturns true if classNode is marked with annotationClass
classNode - A ClassNode to inspectannotationClass - an annotation to look for
classNode - a ClassNode to searchannotationsToLookFor - Annotations to look forWhether the method node has any JUnit annotations
md - The method node