Class AnnotationUtil

java.lang.Object
io.micronaut.core.annotation.AnnotationUtil

@Internal public class AnnotationUtil extends Object
Internal utility methods for annotations. For Internal and framework use only. Do not use in application code.
Since:
1.0
Author:
Graeme Rocher
  • Field Details

    • KOTLIN_METADATA

      public static final String KOTLIN_METADATA
      Constant for Kotlin metadata.
      See Also:
    • INTERNAL_ANNOTATION_NAMES

      public static final List<String> INTERNAL_ANNOTATION_NAMES
    • STEREOTYPE_EXCLUDES

      public static final List<String> STEREOTYPE_EXCLUDES
      Packages excludes from stereotype processing.
    • ZERO_ANNOTATIONS

      public static final Annotation[] ZERO_ANNOTATIONS
      Constant indicating an zero annotation.
    • ZERO_ANNOTATED_ELEMENTS

      public static final AnnotatedElement[] ZERO_ANNOTATED_ELEMENTS
      Constant indicating an zero annotation.
    • ZERO_ANNOTATION_VALUES

      public static final AnnotationValue<?>[] ZERO_ANNOTATION_VALUES
      Constant indicating an zero annotation values.
    • EMPTY_ANNOTATED_ELEMENT

      public static final AnnotatedElement EMPTY_ANNOTATED_ELEMENT
      An empty re-usable element.
    • NULLABLE

      public static final String NULLABLE
      Simple Annotation name used for nullable.
      See Also:
    • NON_NULL

      public static final String NON_NULL
      Simple Annotation name used for non-null.
      See Also:
    • ANN_AROUND

      public static final String ANN_AROUND
      The around annotation type.
      See Also:
    • ANN_AROUND_CONSTRUCT

      public static final String ANN_AROUND_CONSTRUCT
      The around annotation type.
      See Also:
    • ANN_INTRODUCTION

      public static final String ANN_INTRODUCTION
      The around annotation type.
      See Also:
    • ANN_INTERCEPTOR_BINDING

      public static final String ANN_INTERCEPTOR_BINDING
      Name of the interceptor binding type.
      See Also:
    • ANN_INTERCEPTOR_BINDING_QUALIFIER

      public static final String ANN_INTERCEPTOR_BINDING_QUALIFIER
      Name of the interceptor binding qualifier type.
      See Also:
    • ANN_INTERCEPTOR_BINDINGS

      public static final String ANN_INTERCEPTOR_BINDINGS
      Name of the repeatable interceptor bindings type.
      See Also:
    • INJECT

      public static final String INJECT
      The meta annotation used for inject declarations.
      See Also:
    • SCOPE

      public static final String SCOPE
      The meta annotation used for scope declarations.
      See Also:
    • SINGLETON

      public static final String SINGLETON
      The meta annotation used for singleton scope.
      See Also:
    • QUALIFIER

      public static final String QUALIFIER
      The meta annotation used for qualifier declarations.
      See Also:
    • NAMED

      public static final String NAMED
      The meta annotation used for named qualifiers.
      See Also:
    • PRE_DESTROY

      public static final String PRE_DESTROY
      The meta annotation used for pre-destroy declarations.
      See Also:
    • POST_CONSTRUCT

      public static final String POST_CONSTRUCT
      The meta annotation used for post-construct declarations.
      See Also:
    • NON_BINDING_ATTRIBUTE

      public static final String NON_BINDING_ATTRIBUTE
      The annotation attribute containing all the attributes marked as non binding.
      See Also:
    • ANN_INHERITED

      public static final String ANN_INHERITED
      The inherited annotation.
  • Constructor Details

    • AnnotationUtil

      public AnnotationUtil()
  • Method Details

    • findQualifierAnnotations

      public static List<AnnotationValue<Annotation>> findQualifierAnnotations(AnnotationMetadata annotationMetadata)
      Finds qualifier annotations.
      Parameters:
      annotationMetadata - The annotation metadata
      Returns:
      The qualifier annotations
      Since:
      4.0.0
    • findQualifierAnnotationsNames

      public static List<String> findQualifierAnnotationsNames(AnnotationMetadata annotationMetadata)
      Finds qualifier annotations names.
      Parameters:
      annotationMetadata - The annotation metadata
      Returns:
      The qualifier annotations names
      Since:
      4.0.0
    • hasDeclaredQualifierAnnotation

      public static boolean hasDeclaredQualifierAnnotation(AnnotationMetadata annotationMetadata)
      Has qualifier annotations.
      Parameters:
      annotationMetadata - The annotation metadata
      Returns:
      True if qualifier annotation
      Since:
      4.0.0
    • resolveNonBindingMembers

      public static String[] resolveNonBindingMembers(AnnotationMetadata annotationMetadata)
      Resolve non-binding members.
      Parameters:
      annotationMetadata - The annotation metadata
      Returns:
      The non-binding members
      Since:
      4.0.0
    • findQualifierAnnotation

      public static Optional<String> findQualifierAnnotation(AnnotationMetadata annotationMetadata)
      Finds a qualifier annotation.
      Parameters:
      annotationMetadata - The annotation metadata
      Returns:
      A qualifier annotation
      Since:
      4.0.0
    • internListOf

      public static List<String> internListOf(Object... objects)
      Converts the given objects into a set of potentially cached and interned strings contained within an internal pool of lists. See String.intern().

      This method serves the purpose of reducing memory footprint by pooling common lists of annotations in compiled AnnotationMetadata

      Parameters:
      objects - The objects
      Returns:
      A unmodifiable, pooled set of strings
    • internMapOf

      public static Map<String,Object> internMapOf(Object... values)
      Converts the given objects into a map of potentially cached and interned strings where the keys and values are alternating entries in the passed array. See String.intern().

      The values stored at even number positions will be converted to strings and interned.

      Parameters:
      values - The objects
      Returns:
      An unmodifiable set of strings
      See Also:
    • internMapOf

      public static Map<String,Object> internMapOf(String key, Object value)
      Converts the given objects into a map of potentially cached and interned strings where the keys and values are alternating entries in the passed array. See String.intern().

      The values stored at even number positions will be converted to strings and interned.

      Parameters:
      key - The key
      value - The value
      Returns:
      An unmodifiable set of strings
      Since:
      3.0
    • mapOf

      public static Map<String,Object> mapOf(Object... array)
      Create a new immutable Map from an array of values. String values must be sorted!
      Parameters:
      array - The key, value array
      Returns:
      The created map
    • mapOf

      public static Map<String,Object> mapOf(String key1, Object value1)
      Create a new immutable Map. String values must be sorted!
      Parameters:
      key1 - The key 1
      value1 - The value 1
      Returns:
      The created map
    • mapOf

      public static Map<String,Object> mapOf(String key1, Object value1, String key2, Object value2)
      Create a new immutable Map. String values must be sorted!
      Parameters:
      key1 - The key1
      value1 - The value1
      key2 - The key2
      value2 - The value2
      Returns:
      The created map
    • mapOf

      public static Map<String,Object> mapOf(String key1, Object value1, String key2, Object value2, String key3, Object value3)
      Create a new immutable Map. String values must be sorted!
      Parameters:
      key1 - The key1
      value1 - The value1
      key2 - The key2
      value2 - The value2
      key3 - The key3
      value3 - The value3
      Returns:
      The created map
    • mapOf

      public static Map<String,Object> mapOf(String key1, Object value1, String key2, Object value2, String key3, Object value3, String key4, Object value4)
      Create a new immutable Map. String values must be sorted!
      Parameters:
      key1 - The key1
      value1 - The value1
      key2 - The key2
      value2 - The value2
      key3 - The key3
      value3 - The value3
      key4 - The key4
      value4 - The value4
      Returns:
      The created map
    • mapOf

      public static Map<String,Object> mapOf(String key1, Object value1, String key2, Object value2, String key3, Object value3, String key4, Object value4, String key5, Object value5)
      Create a new immutable Map. String values must be sorted!
      Parameters:
      key1 - The key1
      value1 - The value1
      key2 - The key2
      value2 - The value2
      key3 - The key3
      value3 - The value3
      key4 - The key4
      value4 - The value4
      key5 - The key5
      value5 - The value5
      Returns:
      The created map
    • mapOf

      public static Map<String,Object> mapOf(String key1, Object value1, String key2, Object value2, String key3, Object value3, String key4, Object value4, String key5, Object value5, String key6, Object value6)
      Create a new immutable Map. String values must be sorted!
      Parameters:
      key1 - The key1
      value1 - The value1
      key2 - The key2
      value2 - The value2
      key3 - The key3
      value3 - The value3
      key4 - The key4
      value4 - The value4
      key5 - The key5
      value5 - The value5
      key6 - The key6
      value6 - The value6
      Returns:
      The created map
    • mapOf

      public static Map<String,Object> mapOf(String key1, Object value1, String key2, Object value2, String key3, Object value3, String key4, Object value4, String key5, Object value5, String key6, Object value6, String key7, Object value7)
      Create a new immutable Map. String values must be sorted!
      Parameters:
      key1 - The key1
      value1 - The value1
      key2 - The key2
      value2 - The value2
      key3 - The key3
      value3 - The value3
      key4 - The key4
      value4 - The value4
      key5 - The key5
      value5 - The value5
      key6 - The key6
      value6 - The value6
      key7 - The key7
      value7 - The value7
      Returns:
      The created map
    • mapOf

      public static Map<String,Object> mapOf(String key1, Object value1, String key2, Object value2, String key3, Object value3, String key4, Object value4, String key5, Object value5, String key6, Object value6, String key7, Object value7, String key8, Object value8)
      Create a new immutable Map. String values must be sorted!
      Parameters:
      key1 - The key1
      value1 - The value1
      key2 - The key2
      value2 - The value2
      key3 - The key3
      value3 - The value3
      key4 - The key4
      value4 - The value4
      key5 - The key5
      value5 - The value5
      key6 - The key6
      value6 - The value6
      key7 - The key7
      value7 - The value7
      key8 - The key8
      value8 - The value8
      Returns:
      The created map
    • mapOf

      public static Map<String,Object> mapOf(String key1, Object value1, String key2, Object value2, String key3, Object value3, String key4, Object value4, String key5, Object value5, String key6, Object value6, String key7, Object value7, String key8, Object value8, String key9, Object value9)
      Create a new immutable Map. String values must be sorted!
      Parameters:
      key1 - The key1
      value1 - The value1
      key2 - The key2
      value2 - The value2
      key3 - The key3
      value3 - The value3
      key4 - The key4
      value4 - The value4
      key5 - The key5
      value5 - The value5
      key6 - The key6
      value6 - The value6
      key7 - The key7
      value7 - The value7
      key8 - The key8
      value8 - The value8
      key9 - The key9
      value9 - The value9
      Returns:
      The created map
    • mapOf

      public static Map<String,Object> mapOf(String key1, Object value1, String key2, Object value2, String key3, Object value3, String key4, Object value4, String key5, Object value5, String key6, Object value6, String key7, Object value7, String key8, Object value8, String key9, Object value9, String key10, Object value10)
      Create a new immutable Map. String values must be sorted!
      Parameters:
      key1 - The key1
      value1 - The value1
      key2 - The key2
      value2 - The value2
      key3 - The key3
      value3 - The value3
      key4 - The key4
      value4 - The value4
      key5 - The key5
      value5 - The value5
      key6 - The key6
      value6 - The value6
      key7 - The key7
      value7 - The value7
      key8 - The key8
      value8 - The value8
      key9 - The key9
      value9 - The value9
      key10 - The key10
      value10 - The value10
      Returns:
      The created map
    • calculateHashCode

      public static int calculateHashCode(Map<? extends CharSequence,Object> values)
      Calculates the hash code of annotation values.
      Parameters:
      values - The map to calculate values' hash code
      Returns:
      The hash code
    • areEqual

      public static boolean areEqual(Object o1, Object o2)
      Computes whether 2 annotation values are equal.
      Parameters:
      o1 - One object
      o2 - Another object
      Returns:
      Whether both objects are equal