public class

StandardAnnotationMetadata

extends StandardClassMetadata
implements AnnotationMetadata
java.lang.Object
   ↳ org.springframework.core.type.StandardClassMetadata
     ↳ org.springframework.core.type.StandardAnnotationMetadata

Class Overview

AnnotationMetadata implementation that uses standard reflection to introspect a given Class.

Summary

Public Constructors
StandardAnnotationMetadata(Class introspectedClass)
Create a new StandardAnnotationMetadata wrapper for the given Class.
Public Methods
Set<MethodMetadata> getAnnotatedMethods(String annotationType)
Retrieve the method metadata for all methods that are annotated (or meta-annotated) with the given annotation type.
Map<StringObject> getAnnotationAttributes(String annotationType)
Retrieve the attributes of the annotation of the given type, if any (i.e.
Map<StringObject> getAnnotationAttributes(String annotationType, boolean classValuesAsString)
Retrieve the attributes of the annotation of the given type, if any (i.e.
Set<String> getAnnotationTypes()
Return the names of all annotation types defined on the underlying class.
Set<String> getMetaAnnotationTypes(String annotationType)
Return the names of all meta-annotation types defined on the given annotation type of the underlying class.
boolean hasAnnotatedMethods(String annotationType)
Determine whether the underlying class has any methods that are annotated (or meta-annotated) with the given annotation type.
boolean hasAnnotation(String annotationType)
Determine whether the underlying class has an annotation of the given type defined.
boolean hasMetaAnnotation(String annotationType)
Determine whether the underlying class has an annotation that is itself annotated with the meta-annotation of the given type.
boolean isAnnotated(String annotationType)
Determine whether the underlying class has an annotation or meta-annotation of the given type defined.
[Expand]
Inherited Methods
From class org.springframework.core.type.StandardClassMetadata
From class java.lang.Object
From interface org.springframework.core.type.AnnotationMetadata
From interface org.springframework.core.type.ClassMetadata

Public Constructors

public StandardAnnotationMetadata (Class introspectedClass)

Also: SpringCore

Create a new StandardAnnotationMetadata wrapper for the given Class.

Parameters
introspectedClass the Class to introspect

Public Methods

public Set<MethodMetadata> getAnnotatedMethods (String annotationType)

Also: SpringCore

Retrieve the method metadata for all methods that are annotated (or meta-annotated) with the given annotation type.

For any returned method, isAnnotated(String) will return true for the given annotation type.

Parameters
annotationType the annotation type to look for
Returns
  • a Set of MethodMetadata for methods that have a matching annotation. The return value will be an empty set if no methods match the annotation type.

public Map<StringObject> getAnnotationAttributes (String annotationType)

Also: SpringCore

Retrieve the attributes of the annotation of the given type, if any (i.e. if defined on the underlying class, as direct annotation or as meta-annotation).

Parameters
annotationType the annotation type to look for
Returns
  • a Map of attributes, with the attribute name as key (e.g. "value") and the defined attribute value as Map value. This return value will be null if no matching annotation is defined.

public Map<StringObject> getAnnotationAttributes (String annotationType, boolean classValuesAsString)

Also: SpringCore

Retrieve the attributes of the annotation of the given type, if any (i.e. if defined on the underlying class, as direct annotation or as meta-annotation).

Parameters
annotationType the annotation type to look for
classValuesAsString whether to convert class references to String class names for exposure as values in the returned Map, instead of Class references which might potentially have to be loaded first
Returns
  • a Map of attributes, with the attribute name as key (e.g. "value") and the defined attribute value as Map value. This return value will be null if no matching annotation is defined.

public Set<String> getAnnotationTypes ()

Also: SpringCore

Return the names of all annotation types defined on the underlying class.

Returns
  • the annotation type names

public Set<String> getMetaAnnotationTypes (String annotationType)

Also: SpringCore

Return the names of all meta-annotation types defined on the given annotation type of the underlying class.

Parameters
annotationType the meta-annotation type to look for
Returns
  • the meta-annotation type names

public boolean hasAnnotatedMethods (String annotationType)

Also: SpringCore

Determine whether the underlying class has any methods that are annotated (or meta-annotated) with the given annotation type.

public boolean hasAnnotation (String annotationType)

Also: SpringCore

Determine whether the underlying class has an annotation of the given type defined.

Parameters
annotationType the annotation type to look for
Returns
  • whether a matching annotation is defined

public boolean hasMetaAnnotation (String annotationType)

Also: SpringCore

Determine whether the underlying class has an annotation that is itself annotated with the meta-annotation of the given type.

Parameters
annotationType the meta-annotation type to look for
Returns
  • whether a matching meta-annotation is defined

public boolean isAnnotated (String annotationType)

Also: SpringCore

Determine whether the underlying class has an annotation or meta-annotation of the given type defined.

This is equivalent to a "hasAnnotation || hasMetaAnnotation" check. If this method returns true, then getAnnotationAttributes(String) will return a non-null Map.

Parameters
annotationType the annotation type to look for
Returns
  • whether a matching annotation is defined