Package org.springframework.core.type
Interface AnnotationMetadata
- All Superinterfaces:
AnnotatedTypeMetadata
,ClassMetadata
- All Known Implementing Classes:
StandardAnnotationMetadata
Interface that defines abstract access to the annotations of a specific
class, in a form that does not require that class to be loaded yet.
- Since:
- 2.5
- Author:
- Juergen Hoeller, Mark Fisher, Phillip Webb, Sam Brannen
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiongetAnnotatedMethods
(String annotationName) Retrieve the method metadata for all methods that are annotated (or meta-annotated) with the given annotation type.Get the fully qualified class names of all annotation types that are present on the underlying class.Retrieve the method metadata for all user-declared methods on the underlying class, preserving declaration order as far as possible.getMetaAnnotationTypes
(String annotationName) Get the fully qualified class names of all meta-annotation types that are present on the given annotation type on the underlying class.default boolean
hasAnnotatedMethods
(String annotationName) Determine whether the underlying class has any methods that are annotated (or meta-annotated) with the given annotation type.default boolean
hasAnnotation
(String annotationName) Determine whether an annotation of the given type is present on the underlying class.default boolean
hasMetaAnnotation
(String metaAnnotationName) Determine whether the underlying class has an annotation that is itself annotated with the meta-annotation of the given type.static AnnotationMetadata
introspect
(Class<?> type) Factory method to create a newAnnotationMetadata
instance for the given class using standard reflection.Methods inherited from interface org.springframework.core.type.AnnotatedTypeMetadata
getAllAnnotationAttributes, getAllAnnotationAttributes, getAnnotationAttributes, getAnnotationAttributes, getAnnotations, isAnnotated
Methods inherited from interface org.springframework.core.type.ClassMetadata
getClassName, getEnclosingClassName, getInterfaceNames, getMemberClassNames, getSuperClassName, hasEnclosingClass, hasSuperClass, isAbstract, isAnnotation, isConcrete, isFinal, isIndependent, isInterface
-
Method Details
-
getAnnotationTypes
Get the fully qualified class names of all annotation types that are present on the underlying class.- Returns:
- the annotation type names
-
getMetaAnnotationTypes
Get the fully qualified class names of all meta-annotation types that are present on the given annotation type on the underlying class.- Parameters:
annotationName
- the fully qualified class name of the meta-annotation type to look for- Returns:
- the meta-annotation type names, or an empty set if none found
-
hasAnnotation
Determine whether an annotation of the given type is present on the underlying class.- Parameters:
annotationName
- the fully qualified class name of the annotation type to look for- Returns:
true
if a matching annotation is present
-
hasMetaAnnotation
Determine whether the underlying class has an annotation that is itself annotated with the meta-annotation of the given type.- Parameters:
metaAnnotationName
- the fully qualified class name of the meta-annotation type to look for- Returns:
true
if a matching meta-annotation is present
-
hasAnnotatedMethods
Determine whether the underlying class has any methods that are annotated (or meta-annotated) with the given annotation type.- Parameters:
annotationName
- the fully qualified class name of the annotation type to look for
-
getAnnotatedMethods
Retrieve the method metadata for all methods that are annotated (or meta-annotated) with the given annotation type.For any returned method,
AnnotatedTypeMetadata.isAnnotated(java.lang.String)
will returntrue
for the given annotation type.- Parameters:
annotationName
- the fully qualified class name of 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.
-
getDeclaredMethods
Set<MethodMetadata> getDeclaredMethods()Retrieve the method metadata for all user-declared methods on the underlying class, preserving declaration order as far as possible.- Returns:
- a set of
MethodMetadata
- Since:
- 6.0
-
introspect
Factory method to create a newAnnotationMetadata
instance for the given class using standard reflection.- Parameters:
type
- the class to introspect- Returns:
- a new
AnnotationMetadata
instance - Since:
- 5.2
-