org.springframework.core.annotation

Class AnnotationAttributes

  • java.lang.Object
    • java.util.AbstractMap<K,V>
      • java.util.HashMap<K,V>
        • java.util.LinkedHashMap<java.lang.String,java.lang.Object>
          • org.springframework.core.annotation.AnnotationAttributes
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.util.AbstractMap

        java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V>
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      java.lang.Class<? extends java.lang.annotation.Annotation> annotationType()
      Get the type of annotation represented by this AnnotationAttributes.
      static AnnotationAttributes fromMap(java.util.Map<java.lang.String,java.lang.Object> map)
      Return an AnnotationAttributes instance based on the given map.
      AnnotationAttributes getAnnotation(java.lang.String attributeName)
      Get the AnnotationAttributes stored under the specified attributeName.
      <A extends java.lang.annotation.Annotation>
      A
      getAnnotation(java.lang.String attributeName, java.lang.Class<A> annotationType)
      Get the annotation of type annotationType stored under the specified attributeName.
      AnnotationAttributes[] getAnnotationArray(java.lang.String attributeName)
      Get the array of AnnotationAttributes stored under the specified attributeName.
      <A extends java.lang.annotation.Annotation>
      A[]
      getAnnotationArray(java.lang.String attributeName, java.lang.Class<A> annotationType)
      Get the array of type annotationType stored under the specified attributeName.
      boolean getBoolean(java.lang.String attributeName)
      Get the value stored under the specified attributeName as a boolean.
      <T> java.lang.Class<? extends T> getClass(java.lang.String attributeName)
      Get the value stored under the specified attributeName as a class.
      java.lang.Class<?>[] getClassArray(java.lang.String attributeName)
      Get the value stored under the specified attributeName as an array of classes.
      <E extends java.lang.Enum<?>>
      E
      getEnum(java.lang.String attributeName)
      Get the value stored under the specified attributeName as an enum.
      <N extends java.lang.Number>
      N
      getNumber(java.lang.String attributeName)
      Get the value stored under the specified attributeName as a number.
      java.lang.String getString(java.lang.String attributeName)
      Get the value stored under the specified attributeName as a string.
      java.lang.String[] getStringArray(java.lang.String attributeName)
      Get the value stored under the specified attributeName as an array of strings.
      java.lang.Object putIfAbsent(java.lang.String key, java.lang.Object value)
      Store the supplied value in this map under the specified key, unless a value is already stored under the key.
      java.lang.String toString() 
      • Methods inherited from class java.util.LinkedHashMap

        clear, containsValue, entrySet, forEach, get, getOrDefault, keySet, removeEldestEntry, replaceAll, values
      • Methods inherited from class java.util.HashMap

        clone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, put, putAll, remove, remove, replace, replace, size
      • Methods inherited from class java.util.AbstractMap

        equals, hashCode
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Map

        compute, computeIfAbsent, computeIfPresent, containsKey, equals, hashCode, isEmpty, merge, put, putAll, remove, remove, replace, replace, size
    • Constructor Detail

      • AnnotationAttributes

        public AnnotationAttributes()
        Create a new, empty AnnotationAttributes instance.
      • AnnotationAttributes

        public AnnotationAttributes(int initialCapacity)
        Create a new, empty AnnotationAttributes instance with the given initial capacity to optimize performance.
        Parameters:
        initialCapacity - initial size of the underlying map
      • AnnotationAttributes

        public AnnotationAttributes(java.util.Map<java.lang.String,java.lang.Object> map)
        Create a new AnnotationAttributes instance, wrapping the provided map and all its key-value pairs.
        Parameters:
        map - original source of annotation attribute key-value pairs
        See Also:
        fromMap(Map)
      • AnnotationAttributes

        public AnnotationAttributes(AnnotationAttributes other)
        Create a new AnnotationAttributes instance, wrapping the provided map and all its key-value pairs.
        Parameters:
        other - original source of annotation attribute key-value pairs
        See Also:
        fromMap(Map)
      • AnnotationAttributes

        public AnnotationAttributes(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
        Create a new, empty AnnotationAttributes instance for the specified annotationType.
        Parameters:
        annotationType - the type of annotation represented by this AnnotationAttributes instance; never null
        Since:
        4.2
      • AnnotationAttributes

        public AnnotationAttributes(java.lang.String annotationType,
                                    @Nullable
                                    java.lang.ClassLoader classLoader)
        Create a new, empty AnnotationAttributes instance for the specified annotationType.
        Parameters:
        annotationType - the annotation type name represented by this AnnotationAttributes instance; never null
        classLoader - the ClassLoader to try to load the annotation type on, or null to just store the annotation type name
        Since:
        4.3.2
    • Method Detail

      • annotationType

        @Nullable
        public java.lang.Class<? extends java.lang.annotation.Annotation> annotationType()
        Get the type of annotation represented by this AnnotationAttributes.
        Returns:
        the annotation type, or null if unknown
        Since:
        4.2
      • getString

        public java.lang.String getString(java.lang.String attributeName)
        Get the value stored under the specified attributeName as a string.
        Parameters:
        attributeName - the name of the attribute to get; never null or empty
        Returns:
        the value
        Throws:
        java.lang.IllegalArgumentException - if the attribute does not exist or if it is not of the expected type
      • getStringArray

        public java.lang.String[] getStringArray(java.lang.String attributeName)
        Get the value stored under the specified attributeName as an array of strings.

        If the value stored under the specified attributeName is a string, it will be wrapped in a single-element array before returning it.

        Parameters:
        attributeName - the name of the attribute to get; never null or empty
        Returns:
        the value
        Throws:
        java.lang.IllegalArgumentException - if the attribute does not exist or if it is not of the expected type
      • getBoolean

        public boolean getBoolean(java.lang.String attributeName)
        Get the value stored under the specified attributeName as a boolean.
        Parameters:
        attributeName - the name of the attribute to get; never null or empty
        Returns:
        the value
        Throws:
        java.lang.IllegalArgumentException - if the attribute does not exist or if it is not of the expected type
      • getNumber

        public <N extends java.lang.Number> N getNumber(java.lang.String attributeName)
        Get the value stored under the specified attributeName as a number.
        Parameters:
        attributeName - the name of the attribute to get; never null or empty
        Returns:
        the value
        Throws:
        java.lang.IllegalArgumentException - if the attribute does not exist or if it is not of the expected type
      • getEnum

        public <E extends java.lang.Enum<?>> E getEnum(java.lang.String attributeName)
        Get the value stored under the specified attributeName as an enum.
        Parameters:
        attributeName - the name of the attribute to get; never null or empty
        Returns:
        the value
        Throws:
        java.lang.IllegalArgumentException - if the attribute does not exist or if it is not of the expected type
      • getClass

        public <T> java.lang.Class<? extends T> getClass(java.lang.String attributeName)
        Get the value stored under the specified attributeName as a class.
        Parameters:
        attributeName - the name of the attribute to get; never null or empty
        Returns:
        the value
        Throws:
        java.lang.IllegalArgumentException - if the attribute does not exist or if it is not of the expected type
      • getClassArray

        public java.lang.Class<?>[] getClassArray(java.lang.String attributeName)
        Get the value stored under the specified attributeName as an array of classes.

        If the value stored under the specified attributeName is a class, it will be wrapped in a single-element array before returning it.

        Parameters:
        attributeName - the name of the attribute to get; never null or empty
        Returns:
        the value
        Throws:
        java.lang.IllegalArgumentException - if the attribute does not exist or if it is not of the expected type
      • getAnnotation

        public AnnotationAttributes getAnnotation(java.lang.String attributeName)
        Get the AnnotationAttributes stored under the specified attributeName.

        Note: if you expect an actual annotation, invoke getAnnotation(String, Class) instead.

        Parameters:
        attributeName - the name of the attribute to get; never null or empty
        Returns:
        the AnnotationAttributes
        Throws:
        java.lang.IllegalArgumentException - if the attribute does not exist or if it is not of the expected type
      • getAnnotation

        public <A extends java.lang.annotation.Annotation> A getAnnotation(java.lang.String attributeName,
                                                                           java.lang.Class<A> annotationType)
        Get the annotation of type annotationType stored under the specified attributeName.
        Parameters:
        attributeName - the name of the attribute to get; never null or empty
        annotationType - the expected annotation type; never null
        Returns:
        the annotation
        Throws:
        java.lang.IllegalArgumentException - if the attribute does not exist or if it is not of the expected type
        Since:
        4.2
      • getAnnotationArray

        public AnnotationAttributes[] getAnnotationArray(java.lang.String attributeName)
        Get the array of AnnotationAttributes stored under the specified attributeName.

        If the value stored under the specified attributeName is an instance of AnnotationAttributes, it will be wrapped in a single-element array before returning it.

        Note: if you expect an actual array of annotations, invoke getAnnotationArray(String, Class) instead.

        Parameters:
        attributeName - the name of the attribute to get; never null or empty
        Returns:
        the array of AnnotationAttributes
        Throws:
        java.lang.IllegalArgumentException - if the attribute does not exist or if it is not of the expected type
      • getAnnotationArray

        public <A extends java.lang.annotation.Annotation> A[] getAnnotationArray(java.lang.String attributeName,
                                                                                  java.lang.Class<A> annotationType)
        Get the array of type annotationType stored under the specified attributeName.

        If the value stored under the specified attributeName is an Annotation, it will be wrapped in a single-element array before returning it.

        Parameters:
        attributeName - the name of the attribute to get; never null or empty
        annotationType - the expected annotation type; never null
        Returns:
        the annotation array
        Throws:
        java.lang.IllegalArgumentException - if the attribute does not exist or if it is not of the expected type
        Since:
        4.2
      • putIfAbsent

        public java.lang.Object putIfAbsent(java.lang.String key,
                                            java.lang.Object value)
        Store the supplied value in this map under the specified key, unless a value is already stored under the key.
        Specified by:
        putIfAbsent in interface java.util.Map<java.lang.String,java.lang.Object>
        Overrides:
        putIfAbsent in class java.util.HashMap<java.lang.String,java.lang.Object>
        Parameters:
        key - the key under which to store the value
        value - the value to store
        Returns:
        the current value stored in this map, or null if no value was previously stored in this map
        Since:
        4.2
        See Also:
        LinkedHashMap.get(java.lang.Object), HashMap.put(K, V)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.util.AbstractMap<java.lang.String,java.lang.Object>
      • fromMap

        @Nullable
        public static AnnotationAttributes fromMap(@Nullable
                                                             java.util.Map<java.lang.String,java.lang.Object> map)
        Return an AnnotationAttributes instance based on the given map.

        If the map is already an AnnotationAttributes instance, it will be cast and returned immediately without creating a new instance. Otherwise a new instance will be created by passing the supplied map to the AnnotationAttributes(Map) constructor.

        Parameters:
        map - original source of annotation attribute key-value pairs