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
  • Field Details

    • ANN_OVERRIDE

      public static final org.codehaus.groovy.ast.ClassNode ANN_OVERRIDE
    • VALIDATOR_KEY

      public static final String VALIDATOR_KEY
      See Also:
  • Constructor Details

    • GroovyAnnotationMetadataBuilder

      public GroovyAnnotationMetadataBuilder(org.codehaus.groovy.control.SourceUnit sourceUnit, org.codehaus.groovy.control.CompilationUnit compilationUnit)
    • GroovyAnnotationMetadataBuilder

      public GroovyAnnotationMetadataBuilder(org.codehaus.groovy.control.SourceUnit sourceUnit, org.codehaus.groovy.control.CompilationUnit compilationUnit, GroovyNativeElementHelper nativeElementHelper, GroovyVisitorContext visitorContext)
  • 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 metadata for the given element. If the element is a method the class metadata will be included.
      Overrides:
      lookupOrBuildForParameter in class AbstractAnnotationMetadataBuilder<org.codehaus.groovy.ast.AnnotatedNode,org.codehaus.groovy.ast.AnnotationNode>
      Parameters:
      owningType - The owning type
      methodElement - The method element
      parameterElement - 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 class AbstractAnnotationMetadataBuilder<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 class AbstractAnnotationMetadataBuilder<org.codehaus.groovy.ast.AnnotatedNode,org.codehaus.groovy.ast.AnnotationNode>
      Parameters:
      element - The element
      annotationName - 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 class AbstractAnnotationMetadataBuilder<org.codehaus.groovy.ast.AnnotatedNode,org.codehaus.groovy.ast.AnnotationNode>
      Parameters:
      annotationElement - The annotation element
      member - The member
      Returns:
      The annotation member element
    • getOriginatingClassName

      protected String getOriginatingClassName(org.codehaus.groovy.ast.AnnotatedNode originatingElement)
      Specified by:
      getOriginatingClassName in class AbstractAnnotationMetadataBuilder<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 class AbstractAnnotationMetadataBuilder<org.codehaus.groovy.ast.AnnotatedNode,org.codehaus.groovy.ast.AnnotationNode>
      Parameters:
      annotation - The annotation
      Returns:
      The retention policy
    • getElementValidator

      protected AnnotatedElementValidator getElementValidator()
      Description copied from class: AbstractAnnotationMetadataBuilder
      Obtains the element validator.
      Overrides:
      getElementValidator in class AbstractAnnotationMetadataBuilder<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 class AbstractAnnotationMetadataBuilder<org.codehaus.groovy.ast.AnnotatedNode,org.codehaus.groovy.ast.AnnotationNode>
      Parameters:
      originatingElement - The originating element
      error - The error
    • addWarning

      protected void addWarning(@NonNull @NonNull org.codehaus.groovy.ast.AnnotatedNode originatingElement, @NonNull @NonNull String warning)
      Description copied from class: AbstractAnnotationMetadataBuilder
      Adds a warning.
      Specified by:
      addWarning in class AbstractAnnotationMetadataBuilder<org.codehaus.groovy.ast.AnnotatedNode,org.codehaus.groovy.ast.AnnotationNode>
      Parameters:
      originatingElement - The originating element
      warning - 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 class AbstractAnnotationMetadataBuilder<org.codehaus.groovy.ast.AnnotatedNode,org.codehaus.groovy.ast.AnnotationNode>
      Parameters:
      element - The element
      annotation - The annotation type
      Returns:
      True if the annotation is present
    • hasAnnotation

      protected boolean hasAnnotation(org.codehaus.groovy.ast.AnnotatedNode element, String annotation)
      Description copied from class: AbstractAnnotationMetadataBuilder
      Checks whether an annotation is present.
      Specified by:
      hasAnnotation in class AbstractAnnotationMetadataBuilder<org.codehaus.groovy.ast.AnnotatedNode,org.codehaus.groovy.ast.AnnotationNode>
      Parameters:
      element - The element
      annotation - 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 class AbstractAnnotationMetadataBuilder<org.codehaus.groovy.ast.AnnotatedNode,org.codehaus.groovy.ast.AnnotationNode>
      Parameters:
      element - The element
      Returns:
      True if the annotation is present
    • getVisitorContext

      protected VisitorContext getVisitorContext()
      Description copied from class: AbstractAnnotationMetadataBuilder
      Returns the visitor context for this implementation.
      Specified by:
      getVisitorContext in class AbstractAnnotationMetadataBuilder<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 class AbstractAnnotationMetadataBuilder<org.codehaus.groovy.ast.AnnotatedNode,org.codehaus.groovy.ast.AnnotationNode>
      Parameters:
      annotationMirror - The annotation
      Returns:
      The type
    • getRepeatableName

      protected String getRepeatableName(org.codehaus.groovy.ast.AnnotationNode annotationMirror)
      Description copied from class: AbstractAnnotationMetadataBuilder
      Obtain the name of the repeatable annotation if the annotation is one.
      Specified by:
      getRepeatableName in class AbstractAnnotationMetadataBuilder<org.codehaus.groovy.ast.AnnotatedNode,org.codehaus.groovy.ast.AnnotationNode>
      Parameters:
      annotationMirror - The annotation mirror
      Returns:
      Return the name or null
    • getRepeatableContainerNameForType

      protected String getRepeatableContainerNameForType(org.codehaus.groovy.ast.AnnotatedNode annotationType)
      Description copied from class: AbstractAnnotationMetadataBuilder
      Obtain the name of the repeatable annotation if the annotation is one.
      Specified by:
      getRepeatableContainerNameForType in class AbstractAnnotationMetadataBuilder<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 class AbstractAnnotationMetadataBuilder<org.codehaus.groovy.ast.AnnotatedNode,org.codehaus.groovy.ast.AnnotationNode>
      Parameters:
      annotationName - The annotation name
      Returns:
      An optional mirror
    • getAnnotationTypeName

      protected String getAnnotationTypeName(org.codehaus.groovy.ast.AnnotationNode annotationMirror)
      Description copied from class: AbstractAnnotationMetadataBuilder
      Get the given type of the annotation.
      Specified by:
      getAnnotationTypeName in class AbstractAnnotationMetadataBuilder<org.codehaus.groovy.ast.AnnotatedNode,org.codehaus.groovy.ast.AnnotationNode>
      Parameters:
      annotationMirror - The annotation
      Returns:
      The type
    • getElementName

      protected String getElementName(org.codehaus.groovy.ast.AnnotatedNode element)
      Description copied from class: AbstractAnnotationMetadataBuilder
      Get the name for the given element.
      Specified by:
      getElementName in class AbstractAnnotationMetadataBuilder<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 class AbstractAnnotationMetadataBuilder<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 class AbstractAnnotationMetadataBuilder<org.codehaus.groovy.ast.AnnotatedNode,org.codehaus.groovy.ast.AnnotationNode>
      Parameters:
      element - The element
      inheritTypeAnnotations - Whether to inherit type annotations
      declaredOnly - 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 class AbstractAnnotationMetadataBuilder<org.codehaus.groovy.ast.AnnotatedNode,org.codehaus.groovy.ast.AnnotationNode>
      Parameters:
      originatingElement - The originating element
      annotationName - The annotation name
      member - The member being read from
      memberName - The member
      annotationValue - The value
      annotationValues - 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 class AbstractAnnotationMetadataBuilder<org.codehaus.groovy.ast.AnnotatedNode,org.codehaus.groovy.ast.AnnotationNode>
      Parameters:
      annotationName - annotation name
      annotationType - 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 class AbstractAnnotationMetadataBuilder<org.codehaus.groovy.ast.AnnotatedNode,org.codehaus.groovy.ast.AnnotationNode>
      Parameters:
      originatingElement - The originating element
      member - The member
      annotationName - The annotation name
      memberName - The member name
      annotationValue - 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 class AbstractAnnotationMetadataBuilder<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 class AbstractAnnotationMetadataBuilder<org.codehaus.groovy.ast.AnnotatedNode,org.codehaus.groovy.ast.AnnotationNode>
      Type Parameters:
      K - The annotation type
      Parameters:
      originatingElement - The originating element
      member - The member
      annotationType - The type
      Returns:
      The values
    • getAnnotationMemberName

      protected String getAnnotationMemberName(org.codehaus.groovy.ast.AnnotatedNode member)
      Description copied from class: AbstractAnnotationMetadataBuilder
      Read the name of an annotation member.
      Specified by:
      getAnnotationMemberName in class AbstractAnnotationMetadataBuilder<org.codehaus.groovy.ast.AnnotatedNode,org.codehaus.groovy.ast.AnnotationNode>
      Parameters:
      member - The member
      Returns:
      The name