Class MutableAnnotationMetadata

java.lang.Object
io.micronaut.inject.annotation.DefaultAnnotationMetadata
io.micronaut.inject.annotation.MutableAnnotationMetadata
All Implemented Interfaces:
io.micronaut.core.annotation.AnnotationMetadata, io.micronaut.core.annotation.AnnotationSource, Cloneable

public class MutableAnnotationMetadata extends DefaultAnnotationMetadata
A mutable various of DefaultAnnotationMetadata that is used only at build time.
Since:
2.4.0
  • Constructor Details

    • MutableAnnotationMetadata

      public MutableAnnotationMetadata()
      Default constructor.
  • Method Details

    • of

      public static MutableAnnotationMetadata of(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata)
    • hasPropertyExpressions

      public boolean hasPropertyExpressions()
      Specified by:
      hasPropertyExpressions in interface io.micronaut.core.annotation.AnnotationMetadata
      Overrides:
      hasPropertyExpressions in class DefaultAnnotationMetadata
    • hasEvaluatedExpressions

      public boolean hasEvaluatedExpressions()
      Specified by:
      hasEvaluatedExpressions in interface io.micronaut.core.annotation.AnnotationMetadata
      Overrides:
      hasEvaluatedExpressions in class DefaultAnnotationMetadata
    • clone

      public MutableAnnotationMetadata clone()
      Overrides:
      clone in class DefaultAnnotationMetadata
    • getDefaultValues

      @NonNull public @NonNull Map<CharSequence,Object> getDefaultValues(@NonNull @NonNull String annotation)
      Specified by:
      getDefaultValues in interface io.micronaut.core.annotation.AnnotationMetadata
      Overrides:
      getDefaultValues in class DefaultAnnotationMetadata
    • addAnnotation

      public void addAnnotation(String annotation, Map<CharSequence,Object> values)
      Adds an annotation and its member values, if the annotation already exists the data will be merged with existing values replaced.
      Parameters:
      annotation - The annotation
      values - The values
    • addAnnotation

      public void addAnnotation(String annotation, Map<CharSequence,Object> values, RetentionPolicy retentionPolicy)
      Adds an annotation and its member values, if the annotation already exists the data will be merged with existing values replaced.
      Parameters:
      annotation - The annotation
      values - The values
      retentionPolicy - The retention policy
    • addDefaultAnnotationValues

      public final void addDefaultAnnotationValues(String annotation, Map<CharSequence,Object> values)
      Adds an annotation directly declared on the element and its member values, if the annotation already exists the data will be merged with existing values replaced.
      Parameters:
      annotation - The annotation
      values - The values
    • addDefaultAnnotationValues

      public final void addDefaultAnnotationValues(String annotation, Map<CharSequence,Object> values, RetentionPolicy retentionPolicy)
      Adds an annotation directly declared on the element and its member values, if the annotation already exists the data will be merged with existing values replaced.
      Parameters:
      annotation - The annotation
      values - The values
      retentionPolicy - The retention policy
    • addRepeatable

      public void addRepeatable(String annotationName, io.micronaut.core.annotation.AnnotationValue<?> annotationValue)
      Adds a repeatable annotation value. If a value already exists will be added
      Parameters:
      annotationName - The annotation name
      annotationValue - The annotation value
    • addRepeatable

      public void addRepeatable(String annotationName, io.micronaut.core.annotation.AnnotationValue<?> annotationValue, RetentionPolicy retentionPolicy)
      Adds a repeatable annotation value. If a value already exists will be added
      Parameters:
      annotationName - The annotation name
      annotationValue - The annotation value
      retentionPolicy - The retention policy
    • addRepeatableStereotype

      public void addRepeatableStereotype(List<String> parents, String stereotype, io.micronaut.core.annotation.AnnotationValue<?> annotationValue)
      Adds a repeatable stereotype value. If a value already exists will be added
      Parameters:
      parents - The parent annotations
      stereotype - The annotation name
      annotationValue - The annotation value
    • addDeclaredRepeatableStereotype

      public void addDeclaredRepeatableStereotype(List<String> parents, String stereotype, io.micronaut.core.annotation.AnnotationValue<?> annotationValue)
      Adds a repeatable declared stereotype value. If a value already exists will be added
      Parameters:
      parents - The parent annotations
      stereotype - The annotation name
      annotationValue - The annotation value
    • addDeclaredRepeatable

      public void addDeclaredRepeatable(String annotationName, io.micronaut.core.annotation.AnnotationValue<?> annotationValue)
      Adds a repeatable annotation value. If a value already exists will be added
      Parameters:
      annotationName - The annotation name
      annotationValue - The annotation value
    • addDeclaredRepeatable

      public void addDeclaredRepeatable(String annotationName, io.micronaut.core.annotation.AnnotationValue<?> annotationValue, RetentionPolicy retentionPolicy)
      Adds a repeatable annotation value. If a value already exists will be added
      Parameters:
      annotationName - The annotation name
      annotationValue - The annotation value
      retentionPolicy - The retention policy
    • addStereotype

      public final void addStereotype(List<String> parentAnnotations, String stereotype, Map<CharSequence,Object> values)
      Adds a stereotype and its member values, if the annotation already exists the data will be merged with existing values replaced.
      Parameters:
      parentAnnotations - The parent annotations
      stereotype - The annotation
      values - The values
    • addStereotype

      public final void addStereotype(List<String> parentAnnotations, String stereotype, Map<CharSequence,Object> values, RetentionPolicy retentionPolicy)
      Adds a stereotype and its member values, if the annotation already exists the data will be merged with existing values replaced.
      Parameters:
      parentAnnotations - The parent annotations
      stereotype - The annotation
      values - The values
      retentionPolicy - The retention policy
    • addDeclaredStereotype

      public void addDeclaredStereotype(List<String> parentAnnotations, String stereotype, Map<CharSequence,Object> values)
      Adds a stereotype and its member values, if the annotation already exists the data will be merged with existing values replaced.
      Parameters:
      parentAnnotations - The parent annotations
      stereotype - The annotation
      values - The values
    • addDeclaredStereotype

      public void addDeclaredStereotype(List<String> parentAnnotations, String stereotype, Map<CharSequence,Object> values, RetentionPolicy retentionPolicy)
      Adds a stereotype and its member values, if the annotation already exists the data will be merged with existing values replaced.
      Parameters:
      parentAnnotations - The parent annotations
      stereotype - The annotation
      values - The values
      retentionPolicy - The retention policy
    • addDeclaredAnnotation

      public void addDeclaredAnnotation(String annotation, Map<CharSequence,Object> values)
      Adds an annotation directly declared on the element and its member values, if the annotation already exists the data will be merged with existing values replaced.
      Parameters:
      annotation - The annotation
      values - The values
    • addDeclaredAnnotation

      public void addDeclaredAnnotation(String annotation, Map<CharSequence,Object> values, RetentionPolicy retentionPolicy)
      Adds an annotation directly declared on the element and its member values, if the annotation already exists the data will be merged with existing values replaced.
      Parameters:
      annotation - The annotation
      values - The values
      retentionPolicy - The retention policy
    • mutateMember

      @Internal public static MutableAnnotationMetadata mutateMember(MutableAnnotationMetadata annotationMetadata, String annotationName, String member, Object value)

      Sets a member of the given AnnotationMetadata return a new annotation metadata instance without mutating the existing.

      WARNING: for internal use only be the framework

      Parameters:
      annotationMetadata - The metadata
      annotationName - The annotation name
      member - The member
      value - The value
      Returns:
      The metadata
    • newAnnotationValue

      protected <T extends Annotation> io.micronaut.core.annotation.AnnotationValue<T> newAnnotationValue(String annotationType, Map<CharSequence,Object> values)
      Overrides:
      newAnnotationValue in class DefaultAnnotationMetadata
    • addAnnotationMetadata

      @Internal public void addAnnotationMetadata(DefaultAnnotationMetadata annotationMetadata)
      Include the annotation metadata from the other instance of DefaultAnnotationMetadata.
      Parameters:
      annotationMetadata - The annotation metadata
      Since:
      4.0.0
    • addAnnotationMetadata

      @Internal public void addAnnotationMetadata(MutableAnnotationMetadata annotationMetadata)
      Include the annotation metadata from the other instance of DefaultAnnotationMetadata.
      Parameters:
      annotationMetadata - The annotation metadata
      Since:
      4.0.0
    • contributeDefaults

      @Internal public static void contributeDefaults(io.micronaut.core.annotation.AnnotationMetadata target, io.micronaut.core.annotation.AnnotationMetadata source)
      Contributes defaults to the given target.

      WARNING: for internal use only be the framework

      Parameters:
      target - The target
      source - The source
    • contributeDefaults

      @Internal public static void contributeDefaults(io.micronaut.core.annotation.AnnotationMetadata target, AnnotationMetadataHierarchy source)
      Contributes defaults to the given target.

      WARNING: for internal use only be the framework

      Parameters:
      target - The target
      source - The source
      Since:
      4.0.0
    • contributeRepeatable

      @Internal public static void contributeRepeatable(io.micronaut.core.annotation.AnnotationMetadata target, io.micronaut.core.annotation.AnnotationMetadata source)
      Contributes repeatable annotation metadata to the given target.

      WARNING: for internal use only be the framework

      Parameters:
      target - The target
      source - The source
    • mutateMember

      @Internal public static MutableAnnotationMetadata mutateMember(MutableAnnotationMetadata annotationMetadata, String annotationName, Map<CharSequence,Object> members)

      Sets a member of the given AnnotationMetadata return a new annotation metadata instance without mutating the existing.

      WARNING: for internal use only be the framework

      Parameters:
      annotationMetadata - The metadata
      annotationName - The annotation name
      members - The key/value set of members and values
      Returns:
      The metadata
    • removeAnnotationIf

      public <A extends Annotation> void removeAnnotationIf(@NonNull @NonNull Predicate<io.micronaut.core.annotation.AnnotationValue<A>> predicate)
      Removes an annotation for the given predicate.
      Type Parameters:
      A - The annotation
      Parameters:
      predicate - The predicate
    • removeAnnotation

      public void removeAnnotation(String annotationType)
      Removes an annotation for the given annotation type.
      Parameters:
      annotationType - The annotation type
      Since:
      3.0.0
    • removeStereotype

      public void removeStereotype(String annotationType)
      Removes a stereotype annotation for the given annotation type.
      Parameters:
      annotationType - The annotation type
      Since:
      3.0.0
    • findRepeatableAnnotationContainerInternal

      protected String findRepeatableAnnotationContainerInternal(String annotation)
      Description copied from class: DefaultAnnotationMetadata
      Find annotation's repeatable container.
      Overrides:
      findRepeatableAnnotationContainerInternal in class DefaultAnnotationMetadata
      Parameters:
      annotation - The annotation
      Returns:
      the repeatable container or null
    • synthesize

      @Nullable public <T extends Annotation> T synthesize(@NonNull @NonNull Class<T> annotationClass)
      Specified by:
      synthesize in interface io.micronaut.core.annotation.AnnotationSource
    • synthesize

      @Nullable public <T extends Annotation> T synthesize(@NonNull @NonNull Class<T> annotationClass, @NonNull @NonNull String sourceAnnotation)
      Specified by:
      synthesize in interface io.micronaut.core.annotation.AnnotationSource
    • synthesizeDeclared

      @Nullable public <T extends Annotation> T synthesizeDeclared(@NonNull @NonNull Class<T> annotationClass, @NonNull @NonNull String sourceAnnotation)
      Specified by:
      synthesizeDeclared in interface io.micronaut.core.annotation.AnnotationSource
    • synthesizeDeclared

      @Nullable public <T extends Annotation> T synthesizeDeclared(@NonNull @NonNull Class<T> annotationClass)
      Specified by:
      synthesizeDeclared in interface io.micronaut.core.annotation.AnnotationSource
    • synthesizeAll

      @NonNull public @NonNull Annotation[] synthesizeAll()
      Specified by:
      synthesizeAll in interface io.micronaut.core.annotation.AnnotationSource
    • synthesizeDeclared

      @NonNull public @NonNull Annotation[] synthesizeDeclared()
      Specified by:
      synthesizeDeclared in interface io.micronaut.core.annotation.AnnotationSource