Package org.springframework.core.type
Class StandardAnnotationMetadata
java.lang.Object
org.springframework.core.type.StandardClassMetadata
org.springframework.core.type.StandardAnnotationMetadata
- All Implemented Interfaces:
AnnotatedTypeMetadata,AnnotationMetadata,ClassMetadata
AnnotationMetadata implementation that uses standard reflection
to introspect a given Class.- Since:
- 2.5
- Author:
- Juergen Hoeller, Mark Fisher, Chris Beams, Phillip Webb, Sam Brannen
-
Constructor Summary
ConstructorsConstructorDescriptionStandardAnnotationMetadata(Class<?> introspectedClass) Deprecated.StandardAnnotationMetadata(Class<?> introspectedClass, boolean nestedAnnotationsAsMap) Deprecated.since 5.2 in favor of the factory methodAnnotationMetadata.introspect(Class). -
Method Summary
Modifier and TypeMethodDescriptiongetAllAnnotationAttributes(String annotationName, boolean classValuesAsString) Retrieve all attributes of all annotations of the given type, if any (i.e.getAnnotatedMethods(String annotationName) Retrieve the method metadata for all methods that are annotated (or meta-annotated) with the given annotation type.getAnnotationAttributes(String annotationName, boolean classValuesAsString) Retrieve the attributes of the annotation of the given type, if any (i.e.Return annotation details based on the direct annotations of the underlying element.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.booleanhasAnnotatedMethods(String annotationName) Determine whether the underlying class has any methods that are annotated (or meta-annotated) with the given annotation type.Methods inherited from class org.springframework.core.type.StandardClassMetadata
equals, getClassName, getEnclosingClassName, getInterfaceNames, getIntrospectedClass, getMemberClassNames, getSuperClassName, hashCode, isAbstract, isAnnotation, isFinal, isIndependent, isInterface, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.core.type.AnnotatedTypeMetadata
getAllAnnotationAttributes, getAnnotationAttributes, isAnnotatedMethods inherited from interface org.springframework.core.type.AnnotationMetadata
getMetaAnnotationTypes, hasAnnotation, hasMetaAnnotationMethods inherited from interface org.springframework.core.type.ClassMetadata
getClassName, getEnclosingClassName, getInterfaceNames, getMemberClassNames, getSuperClassName, hasEnclosingClass, hasSuperClass, isAbstract, isAnnotation, isConcrete, isFinal, isIndependent, isInterface
-
Constructor Details
-
StandardAnnotationMetadata
Deprecated.since 5.2 in favor of the factory methodAnnotationMetadata.introspect(Class)Create a newStandardAnnotationMetadatawrapper for the given Class.- Parameters:
introspectedClass- the Class to introspect- See Also:
-
StandardAnnotationMetadata
@Deprecated public StandardAnnotationMetadata(Class<?> introspectedClass, boolean nestedAnnotationsAsMap) Deprecated.since 5.2 in favor of the factory methodAnnotationMetadata.introspect(Class). UseMergedAnnotation.asMapfromgetAnnotations()rather thanAnnotatedTypeMetadata.getAnnotationAttributes(String)ifnestedAnnotationsAsMapisfalseCreate a newStandardAnnotationMetadatawrapper for the given Class, providing the option to return any nested annotations or annotation arrays in the form ofAnnotationAttributesinstead of actualAnnotationinstances.- Parameters:
introspectedClass- the Class to introspectnestedAnnotationsAsMap- return nested annotations and annotation arrays asAnnotationAttributesfor compatibility with ASM-basedAnnotationMetadataimplementations- Since:
- 3.1.1
-
-
Method Details
-
getAnnotations
Description copied from interface:AnnotatedTypeMetadataReturn annotation details based on the direct annotations of the underlying element.- Specified by:
getAnnotationsin interfaceAnnotatedTypeMetadata- Returns:
- merged annotations based on the direct annotations
-
getAnnotationTypes
Description copied from interface:AnnotationMetadataGet the fully qualified class names of all annotation types that are present on the underlying class.- Specified by:
getAnnotationTypesin interfaceAnnotationMetadata- Returns:
- the annotation type names
-
getAnnotationAttributes
@Nullable public Map<String,Object> getAnnotationAttributes(String annotationName, boolean classValuesAsString) Description copied from interface:AnnotatedTypeMetadataRetrieve the attributes of the annotation of the given type, if any (i.e. if defined on the underlying element, as direct annotation or meta-annotation), also taking attribute overrides on composed annotations into account.- Specified by:
getAnnotationAttributesin interfaceAnnotatedTypeMetadata- Parameters:
annotationName- the fully qualified class name of the annotation type to look forclassValuesAsString- 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
nullif no matching annotation is defined.
-
getAllAnnotationAttributes
@Nullable public MultiValueMap<String,Object> getAllAnnotationAttributes(String annotationName, boolean classValuesAsString) Description copied from interface:AnnotatedTypeMetadataRetrieve all attributes of all annotations of the given type, if any (i.e. if defined on the underlying element, as direct annotation or meta-annotation). Note that this variant does not take attribute overrides into account.- Specified by:
getAllAnnotationAttributesin interfaceAnnotatedTypeMetadata- Parameters:
annotationName- the fully qualified class name of the annotation type to look forclassValuesAsString- whether to convert class references to String- Returns:
- a MultiMap of attributes, with the attribute name as key (e.g. "value")
and a list of the defined attribute values as Map value. This return value will
be
nullif no matching annotation is defined. - See Also:
-
hasAnnotatedMethods
Description copied from interface:AnnotationMetadataDetermine whether the underlying class has any methods that are annotated (or meta-annotated) with the given annotation type.- Specified by:
hasAnnotatedMethodsin interfaceAnnotationMetadata- Parameters:
annotationName- the fully qualified class name of the annotation type to look for
-
getAnnotatedMethods
Description copied from interface:AnnotationMetadataRetrieve 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 returntruefor the given annotation type.- Specified by:
getAnnotatedMethodsin interfaceAnnotationMetadata- Parameters:
annotationName- the fully qualified class name of the annotation type to look for- Returns:
- a set of
MethodMetadatafor methods that have a matching annotation. The return value will be an empty set if no methods match the annotation type.
-
getDeclaredMethods
Description copied from interface:AnnotationMetadataRetrieve the method metadata for all user-declared methods on the underlying class, preserving declaration order as far as possible.- Specified by:
getDeclaredMethodsin interfaceAnnotationMetadata- Returns:
- a set of
MethodMetadata
-
AnnotationMetadata.introspect(Class)