public class AnnotationAttributes
extends java.util.LinkedHashMap<java.lang.String,java.lang.Object>
LinkedHashMap
subclass representing annotation attribute key/value pairs
as read by Spring's reflection- or 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.Constructor and Description |
---|
AnnotationAttributes()
Create a new, empty
AnnotationAttributes instance. |
AnnotationAttributes(int initialCapacity)
Create a new, empty
AnnotationAttributes instance with the given initial
capacity to optimize performance. |
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. |
Modifier and Type | Method and Description |
---|---|
private <T> T |
doGet(java.lang.String attributeName,
java.lang.Class<T> expectedType) |
static AnnotationAttributes |
fromMap(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 is casted and returned
immediately without creating any new instance; otherwise create a new instance by
wrapping the map with the AnnotationAttributes(Map) constructor. |
AnnotationAttributes |
getAnnotation(java.lang.String attributeName) |
AnnotationAttributes[] |
getAnnotationArray(java.lang.String attributeName) |
boolean |
getBoolean(java.lang.String attributeName) |
<T> java.lang.Class<? extends T> |
getClass(java.lang.String attributeName) |
java.lang.Class<?>[] |
getClassArray(java.lang.String attributeName) |
<E extends java.lang.Enum<?>> |
getEnum(java.lang.String attributeName) |
<N extends java.lang.Number> |
getNumber(java.lang.String attributeName) |
java.lang.String |
getString(java.lang.String attributeName) |
java.lang.String[] |
getStringArray(java.lang.String attributeName) |
java.lang.String |
toString() |
private java.lang.String |
valueToString(java.lang.Object value) |
clone, containsKey, entrySet, isEmpty, keySet, put, putAll, remove, size, values
public AnnotationAttributes()
AnnotationAttributes
instance.public AnnotationAttributes(int initialCapacity)
AnnotationAttributes
instance with the given initial
capacity to optimize performance.initialCapacity
- initial size of the underlying mappublic AnnotationAttributes(java.util.Map<java.lang.String,java.lang.Object> map)
AnnotationAttributes
instance, wrapping the provided map
and all its key/value pairs.map
- original source of annotation attribute key/value pairs to wrapfromMap(Map)
public static AnnotationAttributes fromMap(java.util.Map<java.lang.String,java.lang.Object> map)
AnnotationAttributes
instance based on the given map; if the map
is already an AnnotationAttributes
instance, it is casted and returned
immediately without creating any new instance; otherwise create a new instance by
wrapping the map with the AnnotationAttributes(Map)
constructor.map
- original source of annotation attribute key/value pairspublic java.lang.String getString(java.lang.String attributeName)
public java.lang.String[] getStringArray(java.lang.String attributeName)
public boolean getBoolean(java.lang.String attributeName)
public <N extends java.lang.Number> N getNumber(java.lang.String attributeName)
public <E extends java.lang.Enum<?>> E getEnum(java.lang.String attributeName)
public <T> java.lang.Class<? extends T> getClass(java.lang.String attributeName)
public java.lang.Class<?>[] getClassArray(java.lang.String attributeName)
public AnnotationAttributes getAnnotation(java.lang.String attributeName)
public AnnotationAttributes[] getAnnotationArray(java.lang.String attributeName)
private <T> T doGet(java.lang.String attributeName, java.lang.Class<T> expectedType)
public java.lang.String toString()
toString
in class java.util.AbstractMap<java.lang.String,java.lang.Object>
private java.lang.String valueToString(java.lang.Object value)