org.springframework.core.annotation

## 类 AnnotationAttributes

- java.lang.Object
- - java.util.AbstractMap<K,V>
  - - java.util.HashMap<K,V>
    - - java.util.LinkedHashMap<String,Object>
      - - org.springframework.core.annotation.AnnotationAttributes

- 所有已实现的接口:
    Serializable, Cloneable, Map<String,Object>

      public class AnnotationAttributes
      extends LinkedHashMap<String,Object>

  `LinkedHashMap` subclass representing annotation attribute key-value pairs as read by `AnnotationUtils`, `AnnotatedElementUtils`, and Spring's reflection- and ASM-based `AnnotationMetadata` implementations.

  Provides 'pseudo-reification' to avoid noisy Map generics in the calling code as well as convenience methods for looking up annotation attributes in a type-safe fashion.

  从以下版本开始:
    3.1.1
  作者:
    Chris Beams, Sam Brannen, Juergen Hoeller
  另请参阅:
    `AnnotationUtils.getAnnotationAttributes(java.lang.annotation.Annotation)`, `AnnotatedElementUtils`, 序列化表格

- - ### 嵌套类概要

    - ### 从类继承的嵌套类/接口 java.util.AbstractMap

      `AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>`

  - ### 构造器概要

    构造器
    构造器和说明
    `AnnotationAttributes()` Create a new, empty `AnnotationAttributes` instance.
    `AnnotationAttributes(AnnotationAttributes other)` Create a new `AnnotationAttributes` instance, wrapping the provided map and all its key-value pairs.
    `AnnotationAttributes(Class<? extends Annotation> annotationType)` Create a new, empty `AnnotationAttributes` instance for the specified `annotationType`.
    `AnnotationAttributes(int initialCapacity)` Create a new, empty `AnnotationAttributes` instance with the given initial capacity to optimize performance.
    `AnnotationAttributes(Map<String,Object> map)` Create a new `AnnotationAttributes` instance, wrapping the provided map and all its key-value pairs.
    `AnnotationAttributes(String annotationType, ClassLoader classLoader)` Create a new, empty `AnnotationAttributes` instance for the specified `annotationType`.

  - ### 方法概要

    所有方法 静态方法 实例方法 具体方法
    限定符和类型 | 方法和说明
    --- | ---
    `Class<? extends Annotation>` | `annotationType()` Get the type of annotation represented by this `AnnotationAttributes`.
    `static AnnotationAttributes` | `fromMap(Map<String,Object> map)` Return an `AnnotationAttributes` instance based on the given map.
    `AnnotationAttributes` | `getAnnotation(String attributeName)` Get the `AnnotationAttributes` stored under the specified `attributeName`.
    `<A extends Annotation> A` | `getAnnotation(String attributeName, Class<A> annotationType)` Get the annotation of type `annotationType` stored under the specified `attributeName`.
    `AnnotationAttributes[]` | `getAnnotationArray(String attributeName)` Get the array of `AnnotationAttributes` stored under the specified `attributeName`.
    `<A extends Annotation> A[]` | `getAnnotationArray(String attributeName, Class<A> annotationType)` Get the array of type `annotationType` stored under the specified `attributeName`.
    `boolean` | `getBoolean(String attributeName)` Get the value stored under the specified `attributeName` as a boolean.
    `<T> Class<? extends T>` | `getClass(String attributeName)` Get the value stored under the specified `attributeName` as a class.
    `Class<?>[]` | `getClassArray(String attributeName)` Get the value stored under the specified `attributeName` as an array of classes.
    `<E extends Enum<?>> E` | `getEnum(String attributeName)` Get the value stored under the specified `attributeName` as an enum.
    `<N extends Number> N` | `getNumber(String attributeName)` Get the value stored under the specified `attributeName` as a number.
    `String` | `getString(String attributeName)` Get the value stored under the specified `attributeName` as a string.
    `String[]` | `getStringArray(String attributeName)` Get the value stored under the specified `attributeName` as an array of strings.
    `Object` | `putIfAbsent(String key, Object value)` Store the supplied `value` in this map under the specified `key`, unless a value is already stored under the key.
    `String` | `toString()`

    - ### 从类继承的方法 java.util.LinkedHashMap

      `clear, containsValue, entrySet, forEach, get, getOrDefault, keySet, removeEldestEntry, replaceAll, values`

    - ### 从类继承的方法 java.util.HashMap

      `clone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, put, putAll, remove, remove, replace, replace, size`

    - ### 从类继承的方法 java.util.AbstractMap

      `equals, hashCode`

    - ### 从类继承的方法 java.lang.Object

      `finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### 从接口继承的方法 java.util.Map

      `compute, computeIfAbsent, computeIfPresent, containsKey, equals, hashCode, isEmpty, merge, put, putAll, remove, remove, replace, replace, size`

- - ### 构造器详细资料

    - #### 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.
      参数:
        `initialCapacity` - initial size of the underlying map

    - #### AnnotationAttributes

          public AnnotationAttributes(Map<String,Object> map)

      Create a new `AnnotationAttributes` instance, wrapping the provided map and all its key-value pairs.
      参数:
        `map` - original source of annotation attribute key-value pairs
      另请参阅:
        `fromMap(Map)`

    - #### AnnotationAttributes

          public AnnotationAttributes(AnnotationAttributes other)

      Create a new `AnnotationAttributes` instance, wrapping the provided map and all its key-value pairs.
      参数:
        `other` - original source of annotation attribute key-value pairs
      另请参阅:
        `fromMap(Map)`

    - #### AnnotationAttributes

          public AnnotationAttributes(Class<? extends Annotation> annotationType)

      Create a new, empty `AnnotationAttributes` instance for the specified `annotationType`.
      参数:
        `annotationType` - the type of annotation represented by this `AnnotationAttributes` instance; never `null`
      从以下版本开始:
        4.2

    - #### AnnotationAttributes

          public AnnotationAttributes(String annotationType,
                                      @Nullable
                                      ClassLoader classLoader)

      Create a new, empty `AnnotationAttributes` instance for the specified `annotationType`.
      参数:
        `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
      从以下版本开始:
        4.3.2

  - ### 方法详细资料

    - #### annotationType

          @Nullable
          public Class<? extends Annotation> annotationType()

      Get the type of annotation represented by this `AnnotationAttributes`.
      返回:
        the annotation type, or `null` if unknown
      从以下版本开始:
        4.2

    - #### getString

          public String getString(String attributeName)

      Get the value stored under the specified `attributeName` as a string.
      参数:
        `attributeName` - the name of the attribute to get; never `null` or empty
      返回:
        the value
      抛出:
        `IllegalArgumentException` - if the attribute does not exist or if it is not of the expected type

    - #### getStringArray

          public String[] getStringArray(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.

      参数:
        `attributeName` - the name of the attribute to get; never `null` or empty
      返回:
        the value
      抛出:
        `IllegalArgumentException` - if the attribute does not exist or if it is not of the expected type

    - #### getBoolean

          public boolean getBoolean(String attributeName)

      Get the value stored under the specified `attributeName` as a boolean.
      参数:
        `attributeName` - the name of the attribute to get; never `null` or empty
      返回:
        the value
      抛出:
        `IllegalArgumentException` - if the attribute does not exist or if it is not of the expected type

    - #### getNumber

          public <N extends Number> N getNumber(String attributeName)

      Get the value stored under the specified `attributeName` as a number.
      参数:
        `attributeName` - the name of the attribute to get; never `null` or empty
      返回:
        the value
      抛出:
        `IllegalArgumentException` - if the attribute does not exist or if it is not of the expected type

    - #### getEnum

          public <E extends Enum<?>> E getEnum(String attributeName)

      Get the value stored under the specified `attributeName` as an enum.
      参数:
        `attributeName` - the name of the attribute to get; never `null` or empty
      返回:
        the value
      抛出:
        `IllegalArgumentException` - if the attribute does not exist or if it is not of the expected type

    - #### getClass

          public <T> Class<? extends T> getClass(String attributeName)

      Get the value stored under the specified `attributeName` as a class.
      参数:
        `attributeName` - the name of the attribute to get; never `null` or empty
      返回:
        the value
      抛出:
        `IllegalArgumentException` - if the attribute does not exist or if it is not of the expected type

    - #### getClassArray

          public Class<?>[] getClassArray(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.

      参数:
        `attributeName` - the name of the attribute to get; never `null` or empty
      返回:
        the value
      抛出:
        `IllegalArgumentException` - if the attribute does not exist or if it is not of the expected type

    - #### getAnnotation

          public AnnotationAttributes getAnnotation(String attributeName)

      Get the `AnnotationAttributes` stored under the specified `attributeName`.

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

      参数:
        `attributeName` - the name of the attribute to get; never `null` or empty
      返回:
        the `AnnotationAttributes`
      抛出:
        `IllegalArgumentException` - if the attribute does not exist or if it is not of the expected type

    - #### getAnnotation

          public <A extends Annotation> A getAnnotation(String attributeName,
                                                        Class<A> annotationType)

      Get the annotation of type `annotationType` stored under the specified `attributeName`.
      参数:
        `attributeName` - the name of the attribute to get; never `null` or empty
        `annotationType` - the expected annotation type; never `null`
      返回:
        the annotation
      抛出:
        `IllegalArgumentException` - if the attribute does not exist or if it is not of the expected type
      从以下版本开始:
        4.2

    - #### getAnnotationArray

          public AnnotationAttributes[] getAnnotationArray(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.

      参数:
        `attributeName` - the name of the attribute to get; never `null` or empty
      返回:
        the array of `AnnotationAttributes`
      抛出:
        `IllegalArgumentException` - if the attribute does not exist or if it is not of the expected type

    - #### getAnnotationArray

          public <A extends Annotation> A[] getAnnotationArray(String attributeName,
                                                               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.

      参数:
        `attributeName` - the name of the attribute to get; never `null` or empty
        `annotationType` - the expected annotation type; never `null`
      返回:
        the annotation array
      抛出:
        `IllegalArgumentException` - if the attribute does not exist or if it is not of the expected type
      从以下版本开始:
        4.2

    - #### putIfAbsent

          public Object putIfAbsent(String key,
                                    Object value)

      Store the supplied `value` in this map under the specified `key`, unless a value is already stored under the key.
      指定者:
        `putIfAbsent` 在接口中 `Map<String,Object>`
      覆盖:
        `putIfAbsent` 在类中 `HashMap<String,Object>`
      参数:
        `key` - the key under which to store the value
        `value` - the value to store
      返回:
        the current value stored in this map, or `null` if no value was previously stored in this map
      从以下版本开始:
        4.2
      另请参阅:
        `LinkedHashMap.get(java.lang.Object)`, `HashMap.put(K, V)`

    - #### toString

          public String toString()

      覆盖:
        `toString` 在类中 `AbstractMap<String,Object>`

    - #### fromMap

          @Nullable
          public static AnnotationAttributes fromMap(@Nullable
                                                                Map<String,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.

      参数:
        `map` - original source of annotation attribute key-value pairs