Class GroovyAnnotationMetadataBuilder
java.lang.Object
io.micronaut.inject.annotation.AbstractAnnotationMetadataBuilder<org.codehaus.groovy.ast.AnnotatedNode,org.codehaus.groovy.ast.AnnotationNode>
io.micronaut.ast.groovy.annotation.GroovyAnnotationMetadataBuilder
public class GroovyAnnotationMetadataBuilder
extends AbstractAnnotationMetadataBuilder<org.codehaus.groovy.ast.AnnotatedNode,org.codehaus.groovy.ast.AnnotationNode>
Groovy implementation of
AbstractAnnotationMetadataBuilder
.- Since:
- 1.0
- Author:
- Graeme Rocher
-
Nested Class Summary
Nested classes/interfaces inherited from class io.micronaut.inject.annotation.AbstractAnnotationMetadataBuilder
AbstractAnnotationMetadataBuilder.CachedAnnotationMetadata
-
Field Summary
Modifier and TypeFieldDescriptionstatic final org.codehaus.groovy.ast.ClassNode
static final String
-
Constructor Summary
ConstructorDescriptionGroovyAnnotationMetadataBuilder
(org.codehaus.groovy.control.SourceUnit sourceUnit, org.codehaus.groovy.control.CompilationUnit compilationUnit) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Adds an error.protected void
addWarning
(@NonNull org.codehaus.groovy.ast.AnnotatedNode originatingElement, @NonNull String warning) Adds an warning.protected List<org.codehaus.groovy.ast.AnnotatedNode>
buildHierarchy
(org.codehaus.groovy.ast.AnnotatedNode element, boolean inheritTypeAnnotations, boolean declaredOnly) Build the type hierarchy for the given element.protected VisitorContext
Creates the visitor context for this implementation.protected org.codehaus.groovy.ast.AnnotatedNode
getAnnotationMember
(org.codehaus.groovy.ast.AnnotatedNode annotationElement, CharSequence member) Get the annotation member.protected String
getAnnotationMemberName
(org.codehaus.groovy.ast.AnnotatedNode member) Read the name of an annotation member.protected Optional<org.codehaus.groovy.ast.AnnotatedNode>
getAnnotationMirror
(String annotationName) Return a mirror for the given annotation.protected List<? extends org.codehaus.groovy.ast.AnnotationNode>
getAnnotationsForType
(org.codehaus.groovy.ast.AnnotatedNode element) Obtain the annotations for the given type.protected String
getAnnotationTypeName
(org.codehaus.groovy.ast.AnnotationNode annotationMirror) Get the given type of the annotation.protected <K extends Annotation>
Optional<AnnotationValue<K>>getAnnotationValues
(org.codehaus.groovy.ast.AnnotatedNode originatingElement, org.codehaus.groovy.ast.AnnotatedNode member, Class<K> annotationType) Resolve the annotations values from the given member for the given type.protected String
getElementName
(org.codehaus.groovy.ast.AnnotatedNode element) Get the name for the given element.protected AnnotatedElementValidator
Obtains the element validator.protected String
getOriginatingClassName
(org.codehaus.groovy.ast.AnnotatedNode originatingElement) protected String
getRepeatableName
(org.codehaus.groovy.ast.AnnotationNode annotationMirror) Obtain the name of the repeatable annotation if the annotation is is one.protected String
getRepeatableNameForType
(org.codehaus.groovy.ast.AnnotatedNode annotationType) Obtain the name of the repeatable annotation if the annotation is is one.protected RetentionPolicy
getRetentionPolicy
(@NonNull org.codehaus.groovy.ast.AnnotatedNode annotation) Gets the retention policy for the given annotation.protected org.codehaus.groovy.ast.AnnotatedNode
getTypeForAnnotation
(org.codehaus.groovy.ast.AnnotationNode annotationMirror) Get the type of the given annotation.protected boolean
hasAnnotation
(org.codehaus.groovy.ast.AnnotatedNode element, Class<? extends Annotation> annotation) Checks whether an annotation is present.protected boolean
hasAnnotation
(org.codehaus.groovy.ast.AnnotatedNode element, String annotation) Checks whether an annotation is present.protected boolean
hasAnnotations
(org.codehaus.groovy.ast.AnnotatedNode element) Checks whether any annotations are present on the given element.protected boolean
isExcludedAnnotation
(@NonNull org.codehaus.groovy.ast.AnnotatedNode element, @NonNull String annotationName) Is the given annotation excluded for the specified element.protected boolean
isValidationRequired
(org.codehaus.groovy.ast.AnnotatedNode member) Return whether the given member requires validation.lookupOrBuildForParameter
(org.codehaus.groovy.ast.AnnotatedNode owningType, org.codehaus.groovy.ast.AnnotatedNode methodElement, org.codehaus.groovy.ast.AnnotatedNode parameterElement) Build the meta data for the given element.protected Map<? extends org.codehaus.groovy.ast.AnnotatedNode,
?> readAnnotationDefaultValues
(String annotationName, org.codehaus.groovy.ast.AnnotatedNode annotationType) Read the raw default annotation values from the given annotation.protected void
readAnnotationRawValues
(org.codehaus.groovy.ast.AnnotatedNode originatingElement, String annotationName, org.codehaus.groovy.ast.AnnotatedNode member, String memberName, Object annotationValue, Map<CharSequence, Object> annotationValues) Read the given member and value, applying conversions if necessary, and place the data in the given map.protected Map<? extends org.codehaus.groovy.ast.AnnotatedNode,
?> readAnnotationRawValues
(org.codehaus.groovy.ast.AnnotationNode annotationMirror) Read the raw annotation values from the given annotation.protected Object
readAnnotationValue
(org.codehaus.groovy.ast.AnnotatedNode originatingElement, org.codehaus.groovy.ast.AnnotatedNode member, String annotationName, String memberName, Object annotationValue) Read the given member and value, applying conversions if necessary, and place the data in the given map.Methods inherited from class io.micronaut.inject.annotation.AbstractAnnotationMetadataBuilder
annotate, buildDeclared, buildEvaluatedExpressionReference, clearCaches, clearMutated, copyToRuntime, getAnnotationMappers, getAnnotationTransformers, getCachedAnnotationDefaults, getMappedAnnotationNames, getMappedAnnotationPackages, getRetentionPolicy, isEvaluatedExpression, lookupOrBuild, lookupOrBuildForField, lookupOrBuildForMethod, lookupOrBuildForType, postProcess, readNestedAnnotationValue, removeAnnotation, removeAnnotationIf, removeStereotype, validateAnnotationValue
-
Field Details
-
ANN_OVERRIDE
public static final org.codehaus.groovy.ast.ClassNode ANN_OVERRIDE -
VALIDATOR_KEY
- See Also:
-
-
Constructor Details
-
GroovyAnnotationMetadataBuilder
public GroovyAnnotationMetadataBuilder(org.codehaus.groovy.control.SourceUnit sourceUnit, org.codehaus.groovy.control.CompilationUnit compilationUnit)
-
-
Method Details
-
lookupOrBuildForParameter
public AbstractAnnotationMetadataBuilder.CachedAnnotationMetadata lookupOrBuildForParameter(org.codehaus.groovy.ast.AnnotatedNode owningType, org.codehaus.groovy.ast.AnnotatedNode methodElement, org.codehaus.groovy.ast.AnnotatedNode parameterElement) Description copied from class:AbstractAnnotationMetadataBuilder
Build the meta data for the given element. If the element is a method the class metadata will be included.- Overrides:
lookupOrBuildForParameter
in classAbstractAnnotationMetadataBuilder<org.codehaus.groovy.ast.AnnotatedNode,
org.codehaus.groovy.ast.AnnotationNode> - Parameters:
owningType
- The owning typemethodElement
- The method elementparameterElement
- The parameter element- Returns:
- The
AnnotationMetadata
-
isValidationRequired
protected boolean isValidationRequired(org.codehaus.groovy.ast.AnnotatedNode member) Description copied from class:AbstractAnnotationMetadataBuilder
Return whether the given member requires validation.- Specified by:
isValidationRequired
in classAbstractAnnotationMetadataBuilder<org.codehaus.groovy.ast.AnnotatedNode,
org.codehaus.groovy.ast.AnnotationNode> - Parameters:
member
- The member- Returns:
- True if it is
-
isExcludedAnnotation
protected boolean isExcludedAnnotation(@NonNull @NonNull org.codehaus.groovy.ast.AnnotatedNode element, @NonNull @NonNull String annotationName) Description copied from class:AbstractAnnotationMetadataBuilder
Is the given annotation excluded for the specified element.- Overrides:
isExcludedAnnotation
in classAbstractAnnotationMetadataBuilder<org.codehaus.groovy.ast.AnnotatedNode,
org.codehaus.groovy.ast.AnnotationNode> - Parameters:
element
- The elementannotationName
- The annotation name- Returns:
- True if it is excluded
-
getAnnotationMember
protected org.codehaus.groovy.ast.AnnotatedNode getAnnotationMember(org.codehaus.groovy.ast.AnnotatedNode annotationElement, CharSequence member) Description copied from class:AbstractAnnotationMetadataBuilder
Get the annotation member.- Specified by:
getAnnotationMember
in classAbstractAnnotationMetadataBuilder<org.codehaus.groovy.ast.AnnotatedNode,
org.codehaus.groovy.ast.AnnotationNode> - Parameters:
annotationElement
- The annotation elementmember
- The member- Returns:
- The annotation member element
-
getOriginatingClassName
- Specified by:
getOriginatingClassName
in classAbstractAnnotationMetadataBuilder<org.codehaus.groovy.ast.AnnotatedNode,
org.codehaus.groovy.ast.AnnotationNode>
-
getRetentionPolicy
protected RetentionPolicy getRetentionPolicy(@NonNull @NonNull org.codehaus.groovy.ast.AnnotatedNode annotation) Description copied from class:AbstractAnnotationMetadataBuilder
Gets the retention policy for the given annotation.- Specified by:
getRetentionPolicy
in classAbstractAnnotationMetadataBuilder<org.codehaus.groovy.ast.AnnotatedNode,
org.codehaus.groovy.ast.AnnotationNode> - Parameters:
annotation
- The annotation- Returns:
- The retention policy
-
getElementValidator
Description copied from class:AbstractAnnotationMetadataBuilder
Obtains the element validator.- Overrides:
getElementValidator
in classAbstractAnnotationMetadataBuilder<org.codehaus.groovy.ast.AnnotatedNode,
org.codehaus.groovy.ast.AnnotationNode> - Returns:
- The validator.
-
addError
protected void addError(@NonNull @NonNull org.codehaus.groovy.ast.AnnotatedNode originatingElement, @NonNull @NonNull String error) Description copied from class:AbstractAnnotationMetadataBuilder
Adds an error.- Specified by:
addError
in classAbstractAnnotationMetadataBuilder<org.codehaus.groovy.ast.AnnotatedNode,
org.codehaus.groovy.ast.AnnotationNode> - Parameters:
originatingElement
- The originating elementerror
- The error
-
addWarning
protected void addWarning(@NonNull @NonNull org.codehaus.groovy.ast.AnnotatedNode originatingElement, @NonNull @NonNull String warning) Description copied from class:AbstractAnnotationMetadataBuilder
Adds an warning.- Specified by:
addWarning
in classAbstractAnnotationMetadataBuilder<org.codehaus.groovy.ast.AnnotatedNode,
org.codehaus.groovy.ast.AnnotationNode> - Parameters:
originatingElement
- The originating elementwarning
- The warning
-
hasAnnotation
protected boolean hasAnnotation(org.codehaus.groovy.ast.AnnotatedNode element, Class<? extends Annotation> annotation) Description copied from class:AbstractAnnotationMetadataBuilder
Checks whether an annotation is present.- Specified by:
hasAnnotation
in classAbstractAnnotationMetadataBuilder<org.codehaus.groovy.ast.AnnotatedNode,
org.codehaus.groovy.ast.AnnotationNode> - Parameters:
element
- The elementannotation
- The annotation type- Returns:
- True if the annotation is present
-
hasAnnotation
Description copied from class:AbstractAnnotationMetadataBuilder
Checks whether an annotation is present.- Specified by:
hasAnnotation
in classAbstractAnnotationMetadataBuilder<org.codehaus.groovy.ast.AnnotatedNode,
org.codehaus.groovy.ast.AnnotationNode> - Parameters:
element
- The elementannotation
- The annotation type name- Returns:
- True if the annotation is present
-
hasAnnotations
protected boolean hasAnnotations(org.codehaus.groovy.ast.AnnotatedNode element) Description copied from class:AbstractAnnotationMetadataBuilder
Checks whether any annotations are present on the given element.- Specified by:
hasAnnotations
in classAbstractAnnotationMetadataBuilder<org.codehaus.groovy.ast.AnnotatedNode,
org.codehaus.groovy.ast.AnnotationNode> - Parameters:
element
- The element- Returns:
- True if the annotation is present
-
createVisitorContext
Description copied from class:AbstractAnnotationMetadataBuilder
Creates the visitor context for this implementation.- Specified by:
createVisitorContext
in classAbstractAnnotationMetadataBuilder<org.codehaus.groovy.ast.AnnotatedNode,
org.codehaus.groovy.ast.AnnotationNode> - Returns:
- The visitor context
-
getTypeForAnnotation
protected org.codehaus.groovy.ast.AnnotatedNode getTypeForAnnotation(org.codehaus.groovy.ast.AnnotationNode annotationMirror) Description copied from class:AbstractAnnotationMetadataBuilder
Get the type of the given annotation.- Specified by:
getTypeForAnnotation
in classAbstractAnnotationMetadataBuilder<org.codehaus.groovy.ast.AnnotatedNode,
org.codehaus.groovy.ast.AnnotationNode> - Parameters:
annotationMirror
- The annotation- Returns:
- The type
-
getRepeatableName
Description copied from class:AbstractAnnotationMetadataBuilder
Obtain the name of the repeatable annotation if the annotation is is one.- Specified by:
getRepeatableName
in classAbstractAnnotationMetadataBuilder<org.codehaus.groovy.ast.AnnotatedNode,
org.codehaus.groovy.ast.AnnotationNode> - Parameters:
annotationMirror
- The annotation mirror- Returns:
- Return the name or null
-
getRepeatableNameForType
Description copied from class:AbstractAnnotationMetadataBuilder
Obtain the name of the repeatable annotation if the annotation is is one.- Specified by:
getRepeatableNameForType
in classAbstractAnnotationMetadataBuilder<org.codehaus.groovy.ast.AnnotatedNode,
org.codehaus.groovy.ast.AnnotationNode> - Parameters:
annotationType
- The annotation mirror- Returns:
- Return the name or null
-
getAnnotationMirror
protected Optional<org.codehaus.groovy.ast.AnnotatedNode> getAnnotationMirror(String annotationName) Description copied from class:AbstractAnnotationMetadataBuilder
Return a mirror for the given annotation.- Specified by:
getAnnotationMirror
in classAbstractAnnotationMetadataBuilder<org.codehaus.groovy.ast.AnnotatedNode,
org.codehaus.groovy.ast.AnnotationNode> - Parameters:
annotationName
- The annotation name- Returns:
- An optional mirror
-
getAnnotationTypeName
Description copied from class:AbstractAnnotationMetadataBuilder
Get the given type of the annotation.- Specified by:
getAnnotationTypeName
in classAbstractAnnotationMetadataBuilder<org.codehaus.groovy.ast.AnnotatedNode,
org.codehaus.groovy.ast.AnnotationNode> - Parameters:
annotationMirror
- The annotation- Returns:
- The type
-
getElementName
Description copied from class:AbstractAnnotationMetadataBuilder
Get the name for the given element.- Specified by:
getElementName
in classAbstractAnnotationMetadataBuilder<org.codehaus.groovy.ast.AnnotatedNode,
org.codehaus.groovy.ast.AnnotationNode> - Parameters:
element
- The element- Returns:
- The name
-
getAnnotationsForType
protected List<? extends org.codehaus.groovy.ast.AnnotationNode> getAnnotationsForType(org.codehaus.groovy.ast.AnnotatedNode element) Description copied from class:AbstractAnnotationMetadataBuilder
Obtain the annotations for the given type. This method is also responsible for unwrapping repeatable annotations.For example,
@Parent(value = {@Child, @Child})
should result in the two child annotations being returned from this method instead of the parent annotation.- Specified by:
getAnnotationsForType
in classAbstractAnnotationMetadataBuilder<org.codehaus.groovy.ast.AnnotatedNode,
org.codehaus.groovy.ast.AnnotationNode> - Parameters:
element
- The type element- Returns:
- The annotations
-
buildHierarchy
protected List<org.codehaus.groovy.ast.AnnotatedNode> buildHierarchy(org.codehaus.groovy.ast.AnnotatedNode element, boolean inheritTypeAnnotations, boolean declaredOnly) Description copied from class:AbstractAnnotationMetadataBuilder
Build the type hierarchy for the given element.- Specified by:
buildHierarchy
in classAbstractAnnotationMetadataBuilder<org.codehaus.groovy.ast.AnnotatedNode,
org.codehaus.groovy.ast.AnnotationNode> - Parameters:
element
- The elementinheritTypeAnnotations
- Whether to inherit type annotationsdeclaredOnly
- Whether to only include declared annotations- Returns:
- The type hierarchy
-
readAnnotationRawValues
protected void readAnnotationRawValues(org.codehaus.groovy.ast.AnnotatedNode originatingElement, String annotationName, org.codehaus.groovy.ast.AnnotatedNode member, String memberName, Object annotationValue, Map<CharSequence, Object> annotationValues) Description copied from class:AbstractAnnotationMetadataBuilder
Read the given member and value, applying conversions if necessary, and place the data in the given map.- Specified by:
readAnnotationRawValues
in classAbstractAnnotationMetadataBuilder<org.codehaus.groovy.ast.AnnotatedNode,
org.codehaus.groovy.ast.AnnotationNode> - Parameters:
originatingElement
- The originating elementannotationName
- The annotation namemember
- The member being read frommemberName
- The memberannotationValue
- The valueannotationValues
- The values to populate
-
readAnnotationDefaultValues
protected Map<? extends org.codehaus.groovy.ast.AnnotatedNode,?> readAnnotationDefaultValues(String annotationName, org.codehaus.groovy.ast.AnnotatedNode annotationType) Description copied from class:AbstractAnnotationMetadataBuilder
Read the raw default annotation values from the given annotation.- Specified by:
readAnnotationDefaultValues
in classAbstractAnnotationMetadataBuilder<org.codehaus.groovy.ast.AnnotatedNode,
org.codehaus.groovy.ast.AnnotationNode> - Parameters:
annotationName
- annotation nameannotationType
- the type- Returns:
- The values
-
readAnnotationValue
protected Object readAnnotationValue(org.codehaus.groovy.ast.AnnotatedNode originatingElement, org.codehaus.groovy.ast.AnnotatedNode member, String annotationName, String memberName, Object annotationValue) Description copied from class:AbstractAnnotationMetadataBuilder
Read the given member and value, applying conversions if necessary, and place the data in the given map.- Specified by:
readAnnotationValue
in classAbstractAnnotationMetadataBuilder<org.codehaus.groovy.ast.AnnotatedNode,
org.codehaus.groovy.ast.AnnotationNode> - Parameters:
originatingElement
- The originating elementmember
- The memberannotationName
- The annotation namememberName
- The member nameannotationValue
- The value- Returns:
- The object
-
readAnnotationRawValues
protected Map<? extends org.codehaus.groovy.ast.AnnotatedNode,?> readAnnotationRawValues(org.codehaus.groovy.ast.AnnotationNode annotationMirror) Description copied from class:AbstractAnnotationMetadataBuilder
Read the raw annotation values from the given annotation.- Specified by:
readAnnotationRawValues
in classAbstractAnnotationMetadataBuilder<org.codehaus.groovy.ast.AnnotatedNode,
org.codehaus.groovy.ast.AnnotationNode> - Parameters:
annotationMirror
- The annotation- Returns:
- The values
-
getAnnotationValues
protected <K extends Annotation> Optional<AnnotationValue<K>> getAnnotationValues(org.codehaus.groovy.ast.AnnotatedNode originatingElement, org.codehaus.groovy.ast.AnnotatedNode member, Class<K> annotationType) Description copied from class:AbstractAnnotationMetadataBuilder
Resolve the annotations values from the given member for the given type.- Specified by:
getAnnotationValues
in classAbstractAnnotationMetadataBuilder<org.codehaus.groovy.ast.AnnotatedNode,
org.codehaus.groovy.ast.AnnotationNode> - Type Parameters:
K
- The annotation type- Parameters:
originatingElement
- The originating elementmember
- The memberannotationType
- The type- Returns:
- The values
-
getAnnotationMemberName
Description copied from class:AbstractAnnotationMetadataBuilder
Read the name of an annotation member.- Specified by:
getAnnotationMemberName
in classAbstractAnnotationMetadataBuilder<org.codehaus.groovy.ast.AnnotatedNode,
org.codehaus.groovy.ast.AnnotationNode> - Parameters:
member
- The member- Returns:
- The name
-