public abstract class AbstractGroovyElement extends java.lang.Object implements AnnotationMetadataDelegate, Element
Modifier and Type | Field and Description |
---|---|
protected org.codehaus.groovy.control.CompilationUnit |
compilationUnit |
protected org.codehaus.groovy.control.SourceUnit |
sourceUnit |
protected GroovyVisitorContext |
visitorContext |
EMPTY_ELEMENT_ARRAY
CLASS_NAME_SUFFIX, EMPTY_METADATA, VALUE_MEMBER
EMPTY
Constructor and Description |
---|
AbstractGroovyElement(GroovyVisitorContext visitorContext,
org.codehaus.groovy.ast.AnnotatedNode annotatedNode,
AnnotationMetadata annotationMetadata)
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
protected java.util.Map<java.lang.String,org.codehaus.groovy.ast.ClassNode> |
alignNewGenericsInfo(org.codehaus.groovy.ast.GenericsType[] genericsTypes,
org.codehaus.groovy.ast.GenericsType[] redirectTypes,
java.util.Map<java.lang.String,org.codehaus.groovy.ast.ClassNode> genericsSpec)
Align the given generic types.
|
<T extends java.lang.annotation.Annotation> |
annotate(AnnotationValue<T> annotationValue)
Annotate this element with the given annotation type.
|
<T extends java.lang.annotation.Annotation> |
annotate(java.lang.String annotationType,
java.util.function.Consumer<AnnotationValueBuilder<T>> consumer)
Annotate this element with the given annotation type.
|
boolean |
equals(java.lang.Object o) |
AnnotationMetadata |
getAnnotationMetadata()
Supplies the metadata.
|
protected ClassElement |
getGenericElement(org.codehaus.groovy.control.SourceUnit sourceUnit,
org.codehaus.groovy.ast.ClassNode type,
ClassElement rawElement,
java.util.Map<java.lang.String,org.codehaus.groovy.ast.ClassNode> genericsSpec)
Get a generic element for the given element and data.
|
int |
hashCode() |
boolean |
isPackagePrivate() |
Element |
removeAnnotation(java.lang.String annotationType)
Removes an annotation of the given type from the element.
|
<T extends java.lang.annotation.Annotation> |
removeAnnotationIf(java.util.function.Predicate<AnnotationValue<T>> predicate)
Removes all annotations that pass the given predicate.
|
Element |
removeStereotype(java.lang.String annotationType)
Removes a stereotype of the given name from the element.
|
protected AnnotationMetadata |
resolveAnnotationMetadata(org.codehaus.groovy.ast.ClassNode type)
Resolves the annotation metadata for the given type.
|
protected java.util.Set<ElementModifier> |
resolveModifiers(org.codehaus.groovy.ast.ClassNode classNode)
Resolve modifiers for a class node.
|
protected java.util.Set<ElementModifier> |
resolveModifiers(org.codehaus.groovy.ast.FieldNode fieldNode)
Resolve modifiers for a field node.
|
protected java.util.Set<ElementModifier> |
resolveModifiers(org.codehaus.groovy.ast.MethodNode methodNode)
Resolve modifiers for a method node.
|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
annotate, annotate, annotate, getDescription, getDescription, getDocumentation, getModifiers, getName, getNativeType, getSimpleName, isAbstract, isFinal, isPrivate, isProtected, isPublic, isStatic, removeAnnotation, removeStereotype
booleanValue, booleanValue, booleanValue, booleanValue, classValue, classValue, classValue, classValue, classValues, classValues, classValues, classValues, doubleValue, doubleValue, doubleValue, enumValue, enumValue, enumValue, enumValue, enumValues, enumValues, enumValues, enumValues, findAnnotation, findAnnotation, findDeclaredAnnotation, findDeclaredAnnotation, findRepeatableAnnotation, findRepeatableAnnotation, getAnnotation, getAnnotation, getAnnotationNameByStereotype, getAnnotationNameByStereotype, getAnnotationNames, getAnnotationNamesByStereotype, getAnnotationNamesByStereotype, getAnnotationType, getAnnotationType, getAnnotationTypeByStereotype, getAnnotationTypeByStereotype, getAnnotationTypesByStereotype, getAnnotationTypesByStereotype, getAnnotationTypesByStereotype, getAnnotationValuesByType, getDeclaredAnnotation, getDeclaredAnnotation, getDeclaredAnnotationNameByStereotype, getDeclaredAnnotationNames, getDeclaredAnnotationNamesByStereotype, getDeclaredAnnotationTypeByStereotype, getDeclaredAnnotationTypeByStereotype, getDeclaredAnnotationValuesByType, getDeclaredMetadata, getDefaultValue, getDefaultValue, getDefaultValue, getDefaultValue, getDefaultValues, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValues, getValues, hasAnnotation, hasAnnotation, hasDeclaredAnnotation, hasDeclaredAnnotation, hasDeclaredStereotype, hasDeclaredStereotype, hasDeclaredStereotype, hasPropertyExpressions, hasSimpleAnnotation, hasSimpleDeclaredAnnotation, hasStereotype, hasStereotype, hasStereotype, hasStereotype, intValue, intValue, intValue, isAnnotationPresent, isDeclaredAnnotationPresent, isEmpty, isFalse, isFalse, isPresent, isPresent, isRepeatableAnnotation, isRepeatableAnnotation, isTrue, isTrue, longValue, longValue, stringValue, stringValue, stringValue, stringValue, stringValues, stringValues, stringValues, stringValues, synthesize, synthesize, synthesizeAll, synthesizeAnnotationsByType, synthesizeDeclared, synthesizeDeclared, synthesizeDeclared, synthesizeDeclaredAnnotationsByType
getValues, hasDeclaredStereotype, isAnnotationPresent, isDeclaredAnnotationPresent
isDeclaredNonNull, isDeclaredNullable, isNonNull, isNullable
protected final org.codehaus.groovy.control.SourceUnit sourceUnit
protected final org.codehaus.groovy.control.CompilationUnit compilationUnit
protected final GroovyVisitorContext visitorContext
public AbstractGroovyElement(GroovyVisitorContext visitorContext, org.codehaus.groovy.ast.AnnotatedNode annotatedNode, AnnotationMetadata annotationMetadata)
visitorContext
- The groovy visitor contextannotatedNode
- The annotated nodeannotationMetadata
- The annotation metadatapublic AnnotationMetadata getAnnotationMetadata()
AnnotationMetadataProvider
AnnotationMetadata.EMPTY_METADATA
.getAnnotationMetadata
in interface AnnotationMetadataProvider
AnnotationMetadata
public boolean isPackagePrivate()
isPackagePrivate
in interface Element
@CompileStatic public <T extends java.lang.annotation.Annotation> Element annotate(@NonNull java.lang.String annotationType, @NonNull java.util.function.Consumer<AnnotationValueBuilder<T>> consumer)
Element
annotate
in interface Element
T
- The annotation generic typeannotationType
- The annotation typeconsumer
- A function that receives the AnnotationValueBuilder
public <T extends java.lang.annotation.Annotation> Element annotate(AnnotationValue<T> annotationValue)
Element
public Element removeAnnotation(@NonNull java.lang.String annotationType)
Element
If the annotation features any stereotypes these will also be removed unless there are other annotations that reference the stereotype to be removed.
In the case of repeatable annotations this method will remove all repeated annotations, effectively clearing out all declared repeated annotations of the given type.
removeAnnotation
in interface Element
annotationType
- The annotation typepublic <T extends java.lang.annotation.Annotation> Element removeAnnotationIf(@NonNull java.util.function.Predicate<AnnotationValue<T>> predicate)
Element
removeAnnotationIf
in interface Element
T
- The annotation generic typepredicate
- The predicatepublic Element removeStereotype(@NonNull java.lang.String annotationType)
Element
removeStereotype
in interface Element
annotationType
- The annotation typeprotected java.util.Map<java.lang.String,org.codehaus.groovy.ast.ClassNode> alignNewGenericsInfo(@NonNull org.codehaus.groovy.ast.GenericsType[] genericsTypes, @NonNull org.codehaus.groovy.ast.GenericsType[] redirectTypes, @NonNull java.util.Map<java.lang.String,org.codehaus.groovy.ast.ClassNode> genericsSpec)
genericsTypes
- The generic typesredirectTypes
- The redirect typesgenericsSpec
- The current generics spec@NonNull protected ClassElement getGenericElement(@NonNull org.codehaus.groovy.control.SourceUnit sourceUnit, @NonNull org.codehaus.groovy.ast.ClassNode type, @NonNull ClassElement rawElement, @NonNull java.util.Map<java.lang.String,org.codehaus.groovy.ast.ClassNode> genericsSpec)
sourceUnit
- The source unittype
- The typerawElement
- A raw element to fall back togenericsSpec
- The generics spec@NonNull protected AnnotationMetadata resolveAnnotationMetadata(@NonNull org.codehaus.groovy.ast.ClassNode type)
type
- The typepublic boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
protected java.util.Set<ElementModifier> resolveModifiers(org.codehaus.groovy.ast.MethodNode methodNode)
methodNode
- The method nodeprotected java.util.Set<ElementModifier> resolveModifiers(org.codehaus.groovy.ast.FieldNode fieldNode)
fieldNode
- The field nodeprotected java.util.Set<ElementModifier> resolveModifiers(org.codehaus.groovy.ast.ClassNode classNode)
classNode
- The class node