Class AbstractAnnotationMetadataBuilder<T,​A>

  • Type Parameters:
    T - The element type
    A - The annotation type

    public abstract class AbstractAnnotationMetadataBuilder<T,​A>
    extends java.lang.Object
    An abstract implementation that builds AnnotationMetadata.
    Since:
    1.0
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected abstract void addError​(T originatingElement, java.lang.String error)
      Adds an error.
      static void addMutatedMetadata​(java.lang.String declaringType, java.lang.Object element, io.micronaut.core.annotation.AnnotationMetadata metadata)
      Used to store metadata mutations at compilation time.
      protected abstract void addWarning​(T originatingElement, java.lang.String warning)
      Adds an warning.
      <A2 extends java.lang.annotation.Annotation>
      io.micronaut.core.annotation.AnnotationMetadata
      annotate​(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, io.micronaut.core.annotation.AnnotationValue<A2> annotationValue)
      Annotate an existing annotation metadata object.
      io.micronaut.core.annotation.AnnotationMetadata build​(java.lang.String declaringType, T element)
      Build the meta data for the given element.
      io.micronaut.core.annotation.AnnotationMetadata build​(T element)
      Build the meta data for the given element.
      io.micronaut.core.annotation.AnnotationMetadata buildDeclared​(T element)
      Build only metadata for declared annotations.
      io.micronaut.core.annotation.AnnotationMetadata buildDeclared​(T element, java.util.List<? extends A> annotations, boolean includeTypeAnnotations)
      Build only metadata for declared annotations.
      io.micronaut.core.annotation.AnnotationMetadata buildForMethod​(T element)
      Build the meta data for the given method element excluding any class metadata.
      io.micronaut.core.annotation.AnnotationMetadata buildForParent​(java.lang.String declaringType, T parent, T element)
      Build the meta data for the given parent and method element excluding any class metadata.
      io.micronaut.core.annotation.AnnotationMetadata buildForParent​(T parent, T element)
      Get the annotation metadata for the given element and the given parent.
      io.micronaut.core.annotation.AnnotationMetadata buildForParent​(T parent, T element, boolean inheritTypeAnnotations)
      Build the meta data for the given method element excluding any class metadata.
      io.micronaut.core.annotation.AnnotationMetadata buildForParents​(java.lang.String declaringType, java.util.List<T> parents, T element)
      Build the meta data for the given parents and method element excluding any class metadata.
      io.micronaut.core.annotation.AnnotationMetadata buildForParents​(java.util.List<T> parents, T element)
      Get the annotation metadata for the given element and the given parents.
      protected abstract java.util.List<T> buildHierarchy​(T element, boolean inheritTypeAnnotations, boolean declaredOnly)
      Build the type hierarchy for the given element.
      io.micronaut.core.annotation.AnnotationMetadata buildOverridden​(T element)
      Build metadata for the given element, including any metadata that is inherited via method or type overrides.
      static void clearCaches()
      Used to clear caches at the end of a compilation cycle.
      static void clearMutated()
      Used to clear mutated metadata at the end of a compilation cycle.
      static void copyToRuntime()
      This is used for testing scenarios only where annotation metadata is created without bean creation.
      protected abstract VisitorContext createVisitorContext()
      Creates the visitor context for this implementation.
      protected java.util.List<AnnotationMapper<? extends java.lang.annotation.Annotation>> getAnnotationMappers​(java.lang.String annotationName)
      Obtain the annotation mappers for the given annotation name.
      protected abstract T getAnnotationMember​(T originatingElement, java.lang.CharSequence member)
      Get the annotation member.
      protected abstract java.lang.String getAnnotationMemberName​(T member)
      Read the name of an annotation member.
      protected abstract java.util.Map<java.lang.String,​? extends T> getAnnotationMembers​(java.lang.String annotationType)
      Gets the annotation members for the given type.
      protected abstract java.util.Optional<T> getAnnotationMirror​(java.lang.String annotationName)
      Return a mirror for the given annotation.
      protected abstract java.util.List<? extends A> getAnnotationsForType​(T element)
      Obtain the annotations for the given type.
      protected java.util.List<AnnotationTransformer<java.lang.annotation.Annotation>> getAnnotationTransformers​(java.lang.String annotationName)
      Obtain the transformers mappers for the given annotation name.
      protected abstract java.lang.String getAnnotationTypeName​(A annotationMirror)
      Get the given type of the annotation.
      protected abstract io.micronaut.core.value.OptionalValues<?> getAnnotationValues​(T originatingElement, T member, java.lang.Class<?> annotationType)
      Resolve the annotations values from the given member for the given type.
      protected abstract java.lang.String getDeclaringType​(T element)
      Obtains the declaring type for an element.
      protected abstract java.lang.String getElementName​(T element)
      Get the name for the given element.
      protected AnnotatedElementValidator getElementValidator()
      Obtains the element validator.
      static java.util.Set<java.lang.String> getMappedAnnotationNames()  
      static java.util.Set<java.lang.String> getMappedAnnotationPackages()  
      protected abstract java.lang.String getRepeatableName​(A annotationMirror)
      Obtain the name of the repeatable annotation if the annotation is is one.
      protected abstract java.lang.String getRepeatableNameForType​(T annotationType)
      Obtain the name of the repeatable annotation if the annotation is is one.
      protected abstract java.lang.annotation.RetentionPolicy getRetentionPolicy​(T annotation)
      Gets the retention policy for the given annotation.
      protected abstract T getTypeForAnnotation​(A annotationMirror)
      Get the type of the given annotation.
      protected abstract boolean hasAnnotation​(T element, java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
      Checks whether an annotation is present.
      protected abstract boolean hasAnnotation​(T element, java.lang.String annotation)
      Checks whether an annotation is present.
      protected abstract boolean hasAnnotations​(T element)
      Checks whether any annotations are present on the given element.
      protected abstract boolean hasSimpleAnnotation​(T element, java.lang.String simpleName)
      Returns true if a simple meta annotation is present for the given element and annotation type.
      static boolean isAnnotationMapped​(java.lang.String annotationName)
      Returns whether the given annotation is a mapped annotation.
      protected boolean isExcludedAnnotation​(T element, java.lang.String annotationName)
      Is the given annotation excluded for the specified element.
      protected abstract boolean isInheritedAnnotation​(A annotationMirror)
      Test whether the annotation mirror is inherited.
      protected abstract boolean isInheritedAnnotationType​(T annotationType)
      Test whether the annotation mirror is inherited.
      static boolean isMetadataMutated​(java.lang.String declaringType, java.lang.Object element)
      Used to store metadata mutations at compilation time.
      protected abstract boolean isMethodOrClassElement​(T element)
      Whether the element is a field, method, class or constructor.
      protected abstract boolean isValidationRequired​(T member)
      Return whether the given member requires validation.
      protected java.util.Map<java.lang.CharSequence,​java.lang.Object> populateAnnotationData​(T originatingElement, boolean originatingElementIsSameParent, A annotationMirror, DefaultAnnotationMetadata metadata, boolean isDeclared, java.lang.annotation.RetentionPolicy retentionPolicy, boolean allowAliases)
      Populate the annotation data for the given annotation.
      protected java.util.Map<java.lang.CharSequence,​java.lang.Object> populateAnnotationData​(T originatingElement, T parent, A annotationMirror, DefaultAnnotationMetadata metadata, boolean isDeclared, java.lang.annotation.RetentionPolicy retentionPolicy, boolean allowAliases)
      Populate the annotation data for the given annotation.
      protected abstract java.util.Map<? extends T,​?> readAnnotationDefaultValues​(A annotationMirror)
      Read the raw default annotation values from the given annotation.
      protected abstract java.util.Map<? extends T,​?> readAnnotationDefaultValues​(java.lang.String annotationName, T annotationType)
      Read the raw default annotation values from the given annotation.
      protected abstract java.util.Map<? extends T,​?> readAnnotationRawValues​(A annotationMirror)
      Read the raw annotation values from the given annotation.
      protected abstract void readAnnotationRawValues​(T originatingElement, java.lang.String annotationName, T member, java.lang.String memberName, java.lang.Object annotationValue, java.util.Map<java.lang.CharSequence,​java.lang.Object> annotationValues)
      Read the given member and value, applying conversions if necessary, and place the data in the given map.
      protected abstract java.lang.Object readAnnotationValue​(T originatingElement, T member, java.lang.String memberName, java.lang.Object annotationValue)
      Read the given member and value, applying conversions if necessary, and place the data in the given map.
      protected io.micronaut.core.annotation.AnnotationValue readNestedAnnotationValue​(T originatingElement, A annotationMirror)  
      io.micronaut.core.annotation.AnnotationMetadata removeAnnotation​(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, java.lang.String annotationType)
      Removes an annotation from the given annotation metadata.
      <T1 extends java.lang.annotation.Annotation>
      io.micronaut.core.annotation.AnnotationMetadata
      removeAnnotationIf​(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, java.util.function.Predicate<io.micronaut.core.annotation.AnnotationValue<T1>> predicate)
      Removes an annotation from the metadata for the given predicate.
      io.micronaut.core.annotation.AnnotationMetadata removeStereotype​(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, java.lang.String annotationType)
      Removes an annotation from the given annotation metadata.
      protected void validateAnnotationValue​(T originatingElement, java.lang.String annotationName, T member, java.lang.String memberName, java.lang.Object resolvedValue)
      Validates an annotation value.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AbstractAnnotationMetadataBuilder

        protected AbstractAnnotationMetadataBuilder()
        Default constructor.
    • Method Detail

      • buildDeclared

        public io.micronaut.core.annotation.AnnotationMetadata buildDeclared​(T element)
        Build only metadata for declared annotations.
        Parameters:
        element - The element
        Returns:
        The AnnotationMetadata
      • buildDeclared

        public io.micronaut.core.annotation.AnnotationMetadata buildDeclared​(T element,
                                                                             java.util.List<? extends A> annotations,
                                                                             boolean includeTypeAnnotations)
        Build only metadata for declared annotations.
        Parameters:
        element - The element
        annotations - The annotations
        includeTypeAnnotations - Whether to include type level annotations in the metadata for the element
        Returns:
        The AnnotationMetadata
      • buildOverridden

        public io.micronaut.core.annotation.AnnotationMetadata buildOverridden​(T element)
        Build metadata for the given element, including any metadata that is inherited via method or type overrides.
        Parameters:
        element - The element
        Returns:
        The AnnotationMetadata
      • build

        public io.micronaut.core.annotation.AnnotationMetadata build​(T element)
        Build the meta data for the given element. If the element is a method the class metadata will be included.
        Parameters:
        element - The element
        Returns:
        The AnnotationMetadata
      • build

        public io.micronaut.core.annotation.AnnotationMetadata build​(java.lang.String declaringType,
                                                                     T element)
        Build the meta data for the given element. If the element is a method the class metadata will be included.
        Parameters:
        declaringType - The declaring type
        element - The element
        Returns:
        The AnnotationMetadata
      • isMethodOrClassElement

        protected abstract boolean isMethodOrClassElement​(T element)
        Whether the element is a field, method, class or constructor.
        Parameters:
        element - The element
        Returns:
        True if it is
      • getDeclaringType

        @Nullable
        protected abstract java.lang.String getDeclaringType​(@NonNull
                                                             T element)
        Obtains the declaring type for an element.
        Parameters:
        element - The element
        Returns:
        The declaring type
      • buildForMethod

        public io.micronaut.core.annotation.AnnotationMetadata buildForMethod​(T element)
        Build the meta data for the given method element excluding any class metadata.
        Parameters:
        element - The element
        Returns:
        The AnnotationMetadata
      • buildForParent

        public io.micronaut.core.annotation.AnnotationMetadata buildForParent​(T parent,
                                                                              T element)
        Get the annotation metadata for the given element and the given parent. This method is used for cases when you need to combine annotation metadata for two elements, for example a JavaBean property where the field and the method metadata need to be combined.
        Parameters:
        parent - The parent element
        element - The element
        Returns:
        The AnnotationMetadata
      • buildForParents

        public io.micronaut.core.annotation.AnnotationMetadata buildForParents​(java.util.List<T> parents,
                                                                               T element)
        Get the annotation metadata for the given element and the given parents. This method is used for cases when you need to combine annotation metadata for two elements, for example a JavaBean property where the field and the method metadata need to be combined.
        Parameters:
        parents - The parent elements
        element - The element
        Returns:
        The AnnotationMetadata
      • buildForParent

        public io.micronaut.core.annotation.AnnotationMetadata buildForParent​(java.lang.String declaringType,
                                                                              T parent,
                                                                              T element)
        Build the meta data for the given parent and method element excluding any class metadata.
        Parameters:
        declaringType - The declaring type
        parent - The parent element
        element - The element
        Returns:
        The AnnotationMetadata
      • buildForParents

        public io.micronaut.core.annotation.AnnotationMetadata buildForParents​(java.lang.String declaringType,
                                                                               java.util.List<T> parents,
                                                                               T element)
        Build the meta data for the given parents and method element excluding any class metadata.
        Parameters:
        declaringType - The declaring type
        parents - The parent elements
        element - The element
        Returns:
        The AnnotationMetadata
      • buildForParent

        public io.micronaut.core.annotation.AnnotationMetadata buildForParent​(T parent,
                                                                              T element,
                                                                              boolean inheritTypeAnnotations)
        Build the meta data for the given method element excluding any class metadata.
        Parameters:
        parent - The parent element
        element - The element
        inheritTypeAnnotations - Whether to inherit annotations from type as stereotypes
        Returns:
        The AnnotationMetadata
      • getTypeForAnnotation

        protected abstract T getTypeForAnnotation​(A annotationMirror)
        Get the type of the given annotation.
        Parameters:
        annotationMirror - The annotation
        Returns:
        The type
      • hasAnnotation

        protected abstract boolean hasAnnotation​(T element,
                                                 java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
        Checks whether an annotation is present.
        Parameters:
        element - The element
        annotation - The annotation type
        Returns:
        True if the annotation is present
      • hasAnnotation

        protected abstract boolean hasAnnotation​(T element,
                                                 java.lang.String annotation)
        Checks whether an annotation is present.
        Parameters:
        element - The element
        annotation - The annotation type name
        Returns:
        True if the annotation is present
      • hasAnnotations

        protected abstract boolean hasAnnotations​(T element)
        Checks whether any annotations are present on the given element.
        Parameters:
        element - The element
        Returns:
        True if the annotation is present
      • getAnnotationTypeName

        protected abstract java.lang.String getAnnotationTypeName​(A annotationMirror)
        Get the given type of the annotation.
        Parameters:
        annotationMirror - The annotation
        Returns:
        The type
      • getElementName

        protected abstract java.lang.String getElementName​(T element)
        Get the name for the given element.
        Parameters:
        element - The element
        Returns:
        The name
      • getAnnotationsForType

        protected abstract java.util.List<? extends A> getAnnotationsForType​(T element)
        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.
        Parameters:
        element - The type element
        Returns:
        The annotations
      • buildHierarchy

        protected abstract java.util.List<T> buildHierarchy​(T element,
                                                            boolean inheritTypeAnnotations,
                                                            boolean declaredOnly)
        Build the type hierarchy for the given element.
        Parameters:
        element - The element
        inheritTypeAnnotations - Whether to inherit type annotations
        declaredOnly - Whether to only include declared annotations
        Returns:
        The type hierarchy
      • readAnnotationRawValues

        protected abstract void readAnnotationRawValues​(T originatingElement,
                                                        java.lang.String annotationName,
                                                        T member,
                                                        java.lang.String memberName,
                                                        java.lang.Object annotationValue,
                                                        java.util.Map<java.lang.CharSequence,​java.lang.Object> annotationValues)
        Read the given member and value, applying conversions if necessary, and place the data in the given map.
        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
      • validateAnnotationValue

        protected void validateAnnotationValue​(T originatingElement,
                                               java.lang.String annotationName,
                                               T member,
                                               java.lang.String memberName,
                                               java.lang.Object resolvedValue)
        Validates an annotation value.
        Parameters:
        originatingElement - The originating element
        annotationName - The annotation name
        member - The member
        memberName - The member name
        resolvedValue - The resolved value
      • isValidationRequired

        protected abstract boolean isValidationRequired​(T member)
        Return whether the given member requires validation.
        Parameters:
        member - The member
        Returns:
        True if it is
      • getElementValidator

        @Nullable
        protected AnnotatedElementValidator getElementValidator()
        Obtains the element validator.
        Returns:
        The validator.
      • addError

        protected abstract void addError​(@NonNull
                                         T originatingElement,
                                         @NonNull
                                         java.lang.String error)
        Adds an error.
        Parameters:
        originatingElement - The originating element
        error - The error
      • addWarning

        protected abstract void addWarning​(@NonNull
                                           T originatingElement,
                                           @NonNull
                                           java.lang.String warning)
        Adds an warning.
        Parameters:
        originatingElement - The originating element
        warning - The warning
      • readAnnotationValue

        protected abstract java.lang.Object readAnnotationValue​(T originatingElement,
                                                                T member,
                                                                java.lang.String memberName,
                                                                java.lang.Object annotationValue)
        Read the given member and value, applying conversions if necessary, and place the data in the given map.
        Parameters:
        originatingElement - The originating element
        member - The member
        memberName - The member name
        annotationValue - The value
        Returns:
        The object
      • readAnnotationDefaultValues

        protected abstract java.util.Map<? extends T,​?> readAnnotationDefaultValues​(A annotationMirror)
        Read the raw default annotation values from the given annotation.
        Parameters:
        annotationMirror - The annotation
        Returns:
        The values
      • readAnnotationDefaultValues

        protected abstract java.util.Map<? extends T,​?> readAnnotationDefaultValues​(java.lang.String annotationName,
                                                                                          T annotationType)
        Read the raw default annotation values from the given annotation.
        Parameters:
        annotationName - annotation name
        annotationType - the type
        Returns:
        The values
      • readAnnotationRawValues

        protected abstract java.util.Map<? extends T,​?> readAnnotationRawValues​(A annotationMirror)
        Read the raw annotation values from the given annotation.
        Parameters:
        annotationMirror - The annotation
        Returns:
        The values
      • getAnnotationValues

        protected abstract io.micronaut.core.value.OptionalValues<?> getAnnotationValues​(T originatingElement,
                                                                                         T member,
                                                                                         java.lang.Class<?> annotationType)
        Resolve the annotations values from the given member for the given type.
        Parameters:
        originatingElement - The originating element
        member - The member
        annotationType - The type
        Returns:
        The values
      • getAnnotationMemberName

        protected abstract java.lang.String getAnnotationMemberName​(T member)
        Read the name of an annotation member.
        Parameters:
        member - The member
        Returns:
        The name
      • getRepeatableName

        @Nullable
        protected abstract java.lang.String getRepeatableName​(A annotationMirror)
        Obtain the name of the repeatable annotation if the annotation is is one.
        Parameters:
        annotationMirror - The annotation mirror
        Returns:
        Return the name or null
      • getRepeatableNameForType

        @Nullable
        protected abstract java.lang.String getRepeatableNameForType​(T annotationType)
        Obtain the name of the repeatable annotation if the annotation is is one.
        Parameters:
        annotationType - The annotation mirror
        Returns:
        Return the name or null
      • readNestedAnnotationValue

        protected io.micronaut.core.annotation.AnnotationValue readNestedAnnotationValue​(T originatingElement,
                                                                                         A annotationMirror)
        Parameters:
        originatingElement - The originating element
        annotationMirror - The annotation
        Returns:
        The annotation value
      • getAnnotationMirror

        protected abstract java.util.Optional<T> getAnnotationMirror​(java.lang.String annotationName)
        Return a mirror for the given annotation.
        Parameters:
        annotationName - The annotation name
        Returns:
        An optional mirror
      • populateAnnotationData

        protected java.util.Map<java.lang.CharSequence,​java.lang.Object> populateAnnotationData​(T originatingElement,
                                                                                                      @Nullable
                                                                                                      T parent,
                                                                                                      A annotationMirror,
                                                                                                      DefaultAnnotationMetadata metadata,
                                                                                                      boolean isDeclared,
                                                                                                      java.lang.annotation.RetentionPolicy retentionPolicy,
                                                                                                      boolean allowAliases)
        Populate the annotation data for the given annotation.
        Parameters:
        originatingElement - The element the annotation data originates from
        parent - The parent element
        annotationMirror - The annotation
        metadata - the metadata
        isDeclared - Is the annotation a declared annotation
        retentionPolicy - The retention policy
        allowAliases - Whether aliases are allowed
        Returns:
        The annotation values
      • populateAnnotationData

        protected java.util.Map<java.lang.CharSequence,​java.lang.Object> populateAnnotationData​(T originatingElement,
                                                                                                      boolean originatingElementIsSameParent,
                                                                                                      A annotationMirror,
                                                                                                      DefaultAnnotationMetadata metadata,
                                                                                                      boolean isDeclared,
                                                                                                      java.lang.annotation.RetentionPolicy retentionPolicy,
                                                                                                      boolean allowAliases)
        Populate the annotation data for the given annotation.
        Parameters:
        originatingElement - The element the annotation data originates from
        originatingElementIsSameParent - Whether the originating element is considered a parent element
        annotationMirror - The annotation
        metadata - the metadata
        isDeclared - Is the annotation a declared annotation
        retentionPolicy - The retention policy
        allowAliases - Whether aliases are allowed
        Returns:
        The annotation values
      • getAnnotationMember

        @Nullable
        protected abstract T getAnnotationMember​(T originatingElement,
                                                 java.lang.CharSequence member)
        Get the annotation member.
        Parameters:
        originatingElement - The originatig element
        member - The member
        Returns:
        The annotation member
      • getAnnotationMappers

        @NonNull
        protected java.util.List<AnnotationMapper<? extends java.lang.annotation.Annotation>> getAnnotationMappers​(@NonNull
                                                                                                                   java.lang.String annotationName)
        Obtain the annotation mappers for the given annotation name.
        Parameters:
        annotationName - The annotation name
        Returns:
        The mappers
      • getAnnotationTransformers

        @NonNull
        protected java.util.List<AnnotationTransformer<java.lang.annotation.Annotation>> getAnnotationTransformers​(@NonNull
                                                                                                                   java.lang.String annotationName)
        Obtain the transformers mappers for the given annotation name.
        Parameters:
        annotationName - The annotation name
        Returns:
        The transformers
      • createVisitorContext

        protected abstract VisitorContext createVisitorContext()
        Creates the visitor context for this implementation.
        Returns:
        The visitor context
      • getRetentionPolicy

        @NonNull
        protected abstract java.lang.annotation.RetentionPolicy getRetentionPolicy​(@NonNull
                                                                                   T annotation)
        Gets the retention policy for the given annotation.
        Parameters:
        annotation - The annotation
        Returns:
        The retention policy
      • isExcludedAnnotation

        protected boolean isExcludedAnnotation​(@NonNull
                                               T element,
                                               @NonNull
                                               java.lang.String annotationName)
        Is the given annotation excluded for the specified element.
        Parameters:
        element - The element
        annotationName - The annotation name
        Returns:
        True if it is excluded
      • isInheritedAnnotation

        protected abstract boolean isInheritedAnnotation​(@NonNull
                                                         A annotationMirror)
        Test whether the annotation mirror is inherited.
        Parameters:
        annotationMirror - The mirror
        Returns:
        True if it is
      • isInheritedAnnotationType

        protected abstract boolean isInheritedAnnotationType​(@NonNull
                                                             T annotationType)
        Test whether the annotation mirror is inherited.
        Parameters:
        annotationType - The mirror
        Returns:
        True if it is
      • getAnnotationMembers

        @NonNull
        protected abstract java.util.Map<java.lang.String,​? extends T> getAnnotationMembers​(@NonNull
                                                                                                  java.lang.String annotationType)
        Gets the annotation members for the given type.
        Parameters:
        annotationType - The annotation type
        Returns:
        The members
        Since:
        3.3.0
      • hasSimpleAnnotation

        protected abstract boolean hasSimpleAnnotation​(T element,
                                                       java.lang.String simpleName)
        Returns true if a simple meta annotation is present for the given element and annotation type.
        Parameters:
        element - The element
        simpleName - The simple name, ie Class.getSimpleName()
        Returns:
        True an annotation with the given simple name exists on the element
      • addMutatedMetadata

        @Internal
        public static void addMutatedMetadata​(java.lang.String declaringType,
                                              java.lang.Object element,
                                              io.micronaut.core.annotation.AnnotationMetadata metadata)
        Used to store metadata mutations at compilation time. Not for public consumption.
        Parameters:
        declaringType - The declaring type
        element - The element
        metadata - The metadata
      • isMetadataMutated

        @Internal
        public static boolean isMetadataMutated​(java.lang.String declaringType,
                                                java.lang.Object element)
        Used to store metadata mutations at compilation time. Not for public consumption.
        Parameters:
        declaringType - The declaring type
        element - The element
        Returns:
        True if the annotation metadata was mutated
      • clearMutated

        @Internal
        public static void clearMutated()
        Used to clear mutated metadata at the end of a compilation cycle.
      • clearCaches

        @Internal
        public static void clearCaches()
        Used to clear caches at the end of a compilation cycle.
      • copyToRuntime

        @Internal
        public static void copyToRuntime()
        This is used for testing scenarios only where annotation metadata is created without bean creation. It is needed because at compile time there are no defaults added via DefaultAnnotationMetadata.
      • isAnnotationMapped

        @Internal
        public static boolean isAnnotationMapped​(@Nullable
                                                 java.lang.String annotationName)
        Returns whether the given annotation is a mapped annotation.
        Parameters:
        annotationName - The annotation name
        Returns:
        True if it is
      • getMappedAnnotationNames

        @Internal
        public static java.util.Set<java.lang.String> getMappedAnnotationNames()
        Returns:
        Additional mapped annotation names
      • getMappedAnnotationPackages

        @Internal
        public static java.util.Set<java.lang.String> getMappedAnnotationPackages()
        Returns:
        Additional mapped annotation names
      • annotate

        public <A2 extends java.lang.annotation.Annotation> io.micronaut.core.annotation.AnnotationMetadata annotate​(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata,
                                                                                                                     io.micronaut.core.annotation.AnnotationValue<A2> annotationValue)
        Annotate an existing annotation metadata object.
        Type Parameters:
        A2 - The annotation type
        Parameters:
        annotationMetadata - The annotation metadata
        annotationValue - The annotation value
        Returns:
        The mutated metadata
      • removeAnnotation

        public io.micronaut.core.annotation.AnnotationMetadata removeAnnotation​(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata,
                                                                                java.lang.String annotationType)
        Removes an annotation from the given annotation metadata.
        Parameters:
        annotationMetadata - The annotation metadata
        annotationType - The annotation type
        Returns:
        The updated metadata
        Since:
        3.0.0
      • removeStereotype

        public io.micronaut.core.annotation.AnnotationMetadata removeStereotype​(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata,
                                                                                java.lang.String annotationType)
        Removes an annotation from the given annotation metadata.
        Parameters:
        annotationMetadata - The annotation metadata
        annotationType - The annotation type
        Returns:
        The updated metadata
        Since:
        3.0.0
      • removeAnnotationIf

        @NonNull
        public <T1 extends java.lang.annotation.Annotation> io.micronaut.core.annotation.AnnotationMetadata removeAnnotationIf​(@NonNull
                                                                                                                               io.micronaut.core.annotation.AnnotationMetadata annotationMetadata,
                                                                                                                               @NonNull
                                                                                                                               java.util.function.Predicate<io.micronaut.core.annotation.AnnotationValue<T1>> predicate)
        Removes an annotation from the metadata for the given predicate.
        Type Parameters:
        T1 - The annotation type
        Parameters:
        annotationMetadata - The annotation metadata
        predicate - The predicate
        Returns:
        The potentially modified metadata