public abstract class AbstractGroovyElement extends 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 Map<String,org.codehaus.groovy.ast.ClassNode> |
alignNewGenericsInfo(org.codehaus.groovy.ast.GenericsType[] genericsTypes,
org.codehaus.groovy.ast.GenericsType[] redirectTypes,
Map<String,org.codehaus.groovy.ast.ClassNode> genericsSpec)
Align the given generic types.
|
<T extends Annotation> |
annotate(AnnotationValue<T> annotationValue)
Annotate this element with the given annotation type.
|
<T extends Annotation> |
annotate(String annotationType,
Consumer<AnnotationValueBuilder<T>> consumer)
Annotate this element with the given annotation type.
|
boolean |
equals(Object o) |
AnnotationMetadata |
getAnnotationMetadata()
Supplies the metadata.
|
protected ClassElement |
getGenericElement(org.codehaus.groovy.control.SourceUnit sourceUnit,
org.codehaus.groovy.ast.ClassNode type,
ClassElement rawElement,
Map<String,org.codehaus.groovy.ast.ClassNode> genericsSpec)
Get a generic element for the given element and data.
|
int |
hashCode() |
boolean |
isPackagePrivate() |
Element |
removeAnnotation(String annotationType)
Removes an annotation of the given type from the element.
|
<T extends Annotation> |
removeAnnotationIf(Predicate<AnnotationValue<T>> predicate)
Removes all annotations that pass the given predicate.
|
Element |
removeStereotype(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 Set<ElementModifier> |
resolveModifiers(org.codehaus.groovy.ast.ClassNode classNode)
Resolve modifiers for a class node.
|
protected Set<ElementModifier> |
resolveModifiers(org.codehaus.groovy.ast.FieldNode fieldNode)
Resolve modifiers for a field node.
|
protected 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
getAnnotationValuesByName, getDeclaredAnnotationValuesByName, 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 Annotation> Element annotate(@NonNull String annotationType, @NonNull 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 Annotation> Element annotate(AnnotationValue<T> annotationValue)
Element
public Element removeAnnotation(@NonNull 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 Annotation> Element removeAnnotationIf(@NonNull Predicate<AnnotationValue<T>> predicate)
Element
removeAnnotationIf
in interface Element
T
- The annotation generic typepredicate
- The predicatepublic Element removeStereotype(@NonNull String annotationType)
Element
removeStereotype
in interface Element
annotationType
- The annotation typeprotected Map<String,org.codehaus.groovy.ast.ClassNode> alignNewGenericsInfo(@NonNull org.codehaus.groovy.ast.GenericsType[] genericsTypes, @NonNull org.codehaus.groovy.ast.GenericsType[] redirectTypes, @NonNull Map<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 Map<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 typeprotected Set<ElementModifier> resolveModifiers(org.codehaus.groovy.ast.MethodNode methodNode)
methodNode
- The method nodeprotected Set<ElementModifier> resolveModifiers(org.codehaus.groovy.ast.FieldNode fieldNode)
fieldNode
- The field nodeprotected Set<ElementModifier> resolveModifiers(org.codehaus.groovy.ast.ClassNode classNode)
classNode
- The class node