Top Description Fields Constructors Methods
org.springframework.core.annotation

pack-priv final Class AttributeMethods

extends Object
Class Inheritance
Imports
java.lang.annotation.Annotation, java.lang.reflect.Method, java.util.Arrays, .Comparator, .Map, org.springframework.lang.Nullable, org.springframework.util.Assert, .ConcurrentReferenceHashMap, .ReflectionUtils

Provides a quick way to access the attribute methods of an Annotation with consistent ordering as well as a few useful utility methods.
Authors
Phillip Webb, Sam Brannen
Since
5.2

Field Summary

Modifier and TypeField and Description
private final Class<? extends Annotation>
private final Method[]
pack-priv static final Map<Class<? extends Annotation>, AttributeMethods>
private final boolean[]
private final boolean
private final boolean
private static final Comparator<Method>
pack-priv static final AttributeMethods

Constructor Summary

AccessConstructor and Description
private
AttributeMethods(Class<? extends Annotation> annotationType, Method[] attributeMethods)

Method Summary

Modifier and TypeMethod and Description
private void
pack-priv boolean

Returns:

true if all values are present
canLoad
(Annotation
the annotation to check
annotation
)

Determine if values from the given annotation can be safely accessed without causing any TypeNotPresentExceptions.

pack-priv boolean

Returns:

true if the attribute can throw a TypeNotPresentException
canThrowTypeNotPresentException
(int
the index of the attribute to check
index
)

Determine if the attribute at the specified index could throw a TypeNotPresentException when accessed.

private static AttributeMethods
compute(Class<? extends Annotation> annotationType)

pack-priv static String

Returns:

a description of the attribute
describe
(Method
the attribute to describe
attribute
)

Create a description for the given attribute method suitable to use in exception messages and logs.

pack-priv static String

Returns:

a description of the attribute
describe
(Class<?>
the annotation type
annotationType
,
String
the attribute name
attributeName
)

Create a description for the given attribute method suitable to use in exception messages and logs.

pack-priv static AttributeMethods

Returns:

the attribute methods for the annotation type
forAnnotationType
(Class<? extends Annotation>
the annotation type
annotationType
)

Get the attribute methods for the given annotation type.

pack-priv Method

Returns:

the attribute method or null
get
(String
the attribute name to find
name
)

Get the attribute with the specified name or null if no matching attribute exists.

pack-priv Method

Returns:

the attribute method
get
(int
the index of the attribute to return
index
)

Get the attribute at the specified index.

pack-priv boolean

Returns:

true if there is at least one attribute method with a default value
hasDefaultValueMethod
()

Determine if at least one of the attribute methods has a default value.

pack-priv boolean

Returns:

true if there is at least one attribute method with a nested annotation type
hasNestedAnnotation
()

Determine if at least one of the attribute methods is a nested annotation.

pack-priv int

Returns:

the index of the attribute, or -1
indexOf
(String
the name to find
name
)

Get the index of the attribute with the specified name, or -1 if there is no attribute with the name.

pack-priv int

Returns:

the index of the attribute, or -1
indexOf
(Method
the attribute to find
attribute
)

Get the index of the specified attribute, or -1 if the attribute is not in this collection.

private static boolean
pack-priv int

Returns:

the number of attributes
size
()

Get the number of attributes in this collection.

pack-priv void
validate(Annotation
the annotation to validate
annotation
)

Check if values from the given annotation can be safely accessed without causing any TypeNotPresentExceptions.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

annotationTypeback to summary
private final Class<? extends Annotation> annotationType
Annotations
@Nullable
attributeMethodsback to summary
private final Method[] attributeMethods
cacheback to summary
pack-priv static final Map<Class<? extends Annotation>, AttributeMethods> cache
canThrowTypeNotPresentExceptionback to summary
private final boolean[] canThrowTypeNotPresentException
hasDefaultValueMethodback to summary
private final boolean hasDefaultValueMethod
hasNestedAnnotationback to summary
private final boolean hasNestedAnnotation
methodComparatorback to summary
private static final Comparator<Method> methodComparator
NONEback to summary
pack-priv static final AttributeMethods NONE

Constructor Detail

AttributeMethodsback to summary
private AttributeMethods(Class<? extends Annotation> annotationType, Method[] attributeMethods)

Method Detail

assertAnnotationback to summary
private void assertAnnotation(Annotation annotation)
canLoadback to summary
pack-priv boolean canLoad(Annotation annotation)

Determine if values from the given annotation can be safely accessed without causing any TypeNotPresentExceptions.

This method is designed to cover Google App Engine's late arrival of such exceptions for Class values (instead of the more typical early Class.getAnnotations() failure on a regular JVM).

Parameters
annotation:Annotation

the annotation to check

Returns:boolean

true if all values are present

See Also
validate(Annotation)
canThrowTypeNotPresentExceptionback to summary
pack-priv boolean canThrowTypeNotPresentException(int index)

Determine if the attribute at the specified index could throw a TypeNotPresentException when accessed.

Parameters
index:int

the index of the attribute to check

Returns:boolean

true if the attribute can throw a TypeNotPresentException

computeback to summary
private static AttributeMethods compute(Class<? extends Annotation> annotationType)
describeback to summary
pack-priv static String describe(Method attribute)

Create a description for the given attribute method suitable to use in exception messages and logs.

Parameters
attribute:Method

the attribute to describe

Returns:String

a description of the attribute

describeback to summary
pack-priv static String describe(Class<?> annotationType, String attributeName)

Create a description for the given attribute method suitable to use in exception messages and logs.

Parameters
annotationType:Class<?>

the annotation type

attributeName:String

the attribute name

Returns:String

a description of the attribute

forAnnotationTypeback to summary
pack-priv static AttributeMethods forAnnotationType(Class<? extends Annotation> annotationType)

Get the attribute methods for the given annotation type.

Parameters
annotationType:Class<? extends Annotation>

the annotation type

Returns:AttributeMethods

the attribute methods for the annotation type

getback to summary
pack-priv Method get(String name)

Get the attribute with the specified name or null if no matching attribute exists.

Parameters
name:String

the attribute name to find

Returns:Method

the attribute method or null

Annotations
@Nullable
getback to summary
pack-priv Method get(int index)

Get the attribute at the specified index.

Parameters
index:int

the index of the attribute to return

Returns:Method

the attribute method

Exceptions
IndexOutOfBoundsException:
if the index is out of range (index < 0 || index >= size())
hasDefaultValueMethodback to summary
pack-priv boolean hasDefaultValueMethod()

Determine if at least one of the attribute methods has a default value.

Returns:boolean

true if there is at least one attribute method with a default value

hasNestedAnnotationback to summary
pack-priv boolean hasNestedAnnotation()

Determine if at least one of the attribute methods is a nested annotation.

Returns:boolean

true if there is at least one attribute method with a nested annotation type

indexOfback to summary
pack-priv int indexOf(String name)

Get the index of the attribute with the specified name, or -1 if there is no attribute with the name.

Parameters
name:String

the name to find

Returns:int

the index of the attribute, or -1

indexOfback to summary
pack-priv int indexOf(Method attribute)

Get the index of the specified attribute, or -1 if the attribute is not in this collection.

Parameters
attribute:Method

the attribute to find

Returns:int

the index of the attribute, or -1

isAttributeMethodback to summary
private static boolean isAttributeMethod(Method method)
sizeback to summary
pack-priv int size()

Get the number of attributes in this collection.

Returns:int

the number of attributes

validateback to summary
pack-priv void validate(Annotation annotation)

Check if values from the given annotation can be safely accessed without causing any TypeNotPresentExceptions.

This method is designed to cover Google App Engine's late arrival of such exceptions for Class values (instead of the more typical early Class.getAnnotations() failure on a regular JVM).

Parameters
annotation:Annotation

the annotation to validate

Exceptions
IllegalStateException:
if a declared Class attribute could not be read
See Also
canLoad(Annotation)