Package org.springframework.core.type
Class StandardMethodMetadata
- java.lang.Object
- org.springframework.core.type.StandardMethodMetadata
- All Implemented Interfaces:
AnnotatedTypeMetadata
,MethodMetadata
public class StandardMethodMetadata extends Object implements MethodMetadata
MethodMetadata
implementation that uses standard reflection to introspect a givenMethod
.- Since:
- 3.0
- Author:
- Juergen Hoeller, Mark Pollack, Chris Beams, Phillip Webb
Constructor Summary
Constructors Constructor Description StandardMethodMetadata(Method introspectedMethod)
Create a new StandardMethodMetadata wrapper for the given Method.StandardMethodMetadata(Method introspectedMethod, boolean nestedAnnotationsAsMap)
Create a new StandardMethodMetadata wrapper for the given Method, providing the option to return any nested annotations or annotation arrays in the form ofAnnotationAttributes
instead of actualAnnotation
instances.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MultiValueMap<String,Object>
getAllAnnotationAttributes(String annotationName)
Retrieve all attributes of all annotations of the given type, if any (i.e.MultiValueMap<String,Object>
getAllAnnotationAttributes(String annotationName, boolean classValuesAsString)
Retrieve all attributes of all annotations of the given type, if any (i.e.Map<String,Object>
getAnnotationAttributes(String annotationName)
Retrieve the attributes of the annotation of the given type, if any (i.e.Map<String,Object>
getAnnotationAttributes(String annotationName, boolean classValuesAsString)
Retrieve the attributes of the annotation of the given type, if any (i.e.String
getDeclaringClassName()
Return the fully-qualified name of the class that declares this method.Method
getIntrospectedMethod()
Return the underlying Method.String
getMethodName()
Return the name of the method.String
getReturnTypeName()
Return the fully-qualified name of this method's declared return type.boolean
isAbstract()
Return whether the underlying method is effectively abstract: i.e.boolean
isAnnotated(String annotationName)
Determine whether the underlying element has an annotation or meta-annotation of the given type defined.boolean
isFinal()
Return whether the underlying method is marked as 'final'.boolean
isOverridable()
Return whether the underlying method is overridable, i.e.boolean
isStatic()
Return whether the underlying method is declared as 'static'.
Constructor Detail
StandardMethodMetadata
public StandardMethodMetadata(Method introspectedMethod)
Create a new StandardMethodMetadata wrapper for the given Method.- Parameters:
introspectedMethod
- the Method to introspect
StandardMethodMetadata
public StandardMethodMetadata(Method introspectedMethod, boolean nestedAnnotationsAsMap)
Create a new StandardMethodMetadata wrapper for the given Method, providing the option to return any nested annotations or annotation arrays in the form ofAnnotationAttributes
instead of actualAnnotation
instances.- Parameters:
introspectedMethod
- the Method to introspectnestedAnnotationsAsMap
- return nested annotations and annotation arrays asAnnotationAttributes
for compatibility with ASM-basedAnnotationMetadata
implementations- Since:
- 3.1.1
Method Detail
getIntrospectedMethod
public final Method getIntrospectedMethod()
Return the underlying Method.
getMethodName
public String getMethodName()
Description copied from interface:MethodMetadata
Return the name of the method.- Specified by:
getMethodName
in interfaceMethodMetadata
getDeclaringClassName
public String getDeclaringClassName()
Description copied from interface:MethodMetadata
Return the fully-qualified name of the class that declares this method.- Specified by:
getDeclaringClassName
in interfaceMethodMetadata
getReturnTypeName
public String getReturnTypeName()
Description copied from interface:MethodMetadata
Return the fully-qualified name of this method's declared return type.- Specified by:
getReturnTypeName
in interfaceMethodMetadata
isAbstract
public boolean isAbstract()
Description copied from interface:MethodMetadata
Return whether the underlying method is effectively abstract: i.e. marked as abstract on a class or declared as a regular, non-default method in an interface.- Specified by:
isAbstract
in interfaceMethodMetadata
isStatic
public boolean isStatic()
Description copied from interface:MethodMetadata
Return whether the underlying method is declared as 'static'.- Specified by:
isStatic
in interfaceMethodMetadata
isFinal
public boolean isFinal()
Description copied from interface:MethodMetadata
Return whether the underlying method is marked as 'final'.- Specified by:
isFinal
in interfaceMethodMetadata
isOverridable
public boolean isOverridable()
Description copied from interface:MethodMetadata
Return whether the underlying method is overridable, i.e. not marked as static, final or private.- Specified by:
isOverridable
in interfaceMethodMetadata
isAnnotated
public boolean isAnnotated(String annotationName)
Description copied from interface:AnnotatedTypeMetadata
Determine whether the underlying element has an annotation or meta-annotation of the given type defined.If this method returns
true
, thenAnnotatedTypeMetadata.getAnnotationAttributes(java.lang.String)
will return a non-null Map.- Specified by:
isAnnotated
in interfaceAnnotatedTypeMetadata
- Parameters:
annotationName
- the fully qualified class name of the annotation type to look for- Returns:
- whether a matching annotation is defined
getAnnotationAttributes
public Map<String,Object> getAnnotationAttributes(String annotationName)
Description copied from interface:AnnotatedTypeMetadata
Retrieve 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:
getAnnotationAttributes
in interfaceAnnotatedTypeMetadata
- Parameters:
annotationName
- the fully qualified class name of 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.
getAnnotationAttributes
public Map<String,Object> getAnnotationAttributes(String annotationName, boolean classValuesAsString)
Description copied from interface:AnnotatedTypeMetadata
Retrieve 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:
getAnnotationAttributes
in 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
null
if no matching annotation is defined.
getAllAnnotationAttributes
public MultiValueMap<String,Object> getAllAnnotationAttributes(String annotationName)
Description copied from interface:AnnotatedTypeMetadata
Retrieve 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:
getAllAnnotationAttributes
in interfaceAnnotatedTypeMetadata
- Parameters:
annotationName
- the fully qualified class name of the annotation type to look for- 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
null
if no matching annotation is defined. - See Also:
AnnotatedTypeMetadata.getAllAnnotationAttributes(String, boolean)
getAllAnnotationAttributes
public MultiValueMap<String,Object> getAllAnnotationAttributes(String annotationName, boolean classValuesAsString)
Description copied from interface:AnnotatedTypeMetadata
Retrieve 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:
getAllAnnotationAttributes
in 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
null
if no matching annotation is defined. - See Also:
AnnotatedTypeMetadata.getAllAnnotationAttributes(String)