Class AnnotatedMethod
java.lang.Object
org.springframework.core.annotation.AnnotatedMethod
- Direct Known Subclasses:
HandlerMethod
,HandlerMethod
A convenient wrapper for a
Method
handle, providing deep annotation
introspection on methods and method parameters, including the exposure of
interface-declared parameter annotations from the concrete target method.- Since:
- 6.1
- Author:
- Juergen Hoeller
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected class
A MethodParameter with AnnotatedMethod-specific behavior. -
Constructor Summary
ModifierConstructorDescriptionAnnotatedMethod
(Method method) Create an instance that wraps the givenMethod
.protected
AnnotatedMethod
(AnnotatedMethod annotatedMethod) Copy constructor for use in subclasses. -
Method Summary
Modifier and TypeMethodDescriptionboolean
protected static Object
findProvidedArgument
(MethodParameter parameter, Object... providedArgs) protected static String
formatArgumentError
(MethodParameter param, String message) protected final Method
If the annotated method is a bridge method, this method returns the bridged (user-defined) method.protected Class<?>
Expose the containing class for method parameters.final Method
Return the annotated method.<A extends Annotation>
AgetMethodAnnotation
(Class<A> annotationType) Return a single annotation on the underlying method, traversing its super methods if no annotation can be found on the given method itself.final MethodParameter[]
Return the method parameters for thisAnnotatedMethod
.Return aMethodParameter
for the declared return type.getReturnValueType
(Object returnValue) Return aMethodParameter
for the actual return value type.int
hashCode()
<A extends Annotation>
booleanhasMethodAnnotation
(Class<A> annotationType) Determine if an annotation of the given type is present or meta-present on the method.boolean
isVoid()
Returntrue
if the method's return type is void,false
otherwise.toString()
-
Constructor Details
-
AnnotatedMethod
Create an instance that wraps the givenMethod
.- Parameters:
method
- theMethod
handle to wrap
-
AnnotatedMethod
Copy constructor for use in subclasses.
-
-
Method Details
-
getMethod
Return the annotated method. -
getBridgedMethod
If the annotated method is a bridge method, this method returns the bridged (user-defined) method. Otherwise, it returns the same method asgetMethod()
. -
getContainingClass
Expose the containing class for method parameters.- See Also:
-
getMethodParameters
Return the method parameters for thisAnnotatedMethod
. -
getReturnType
Return aMethodParameter
for the declared return type. -
getReturnValueType
Return aMethodParameter
for the actual return value type. -
isVoid
public boolean isVoid()Returntrue
if the method's return type is void,false
otherwise. -
getMethodAnnotation
Return a single annotation on the underlying method, traversing its super methods if no annotation can be found on the given method itself.Supports merged composed annotations with attribute overrides.
- Parameters:
annotationType
- the annotation type to look for- Returns:
- the annotation, or
null
if none found - See Also:
-
hasMethodAnnotation
Determine if an annotation of the given type is present or meta-present on the method.- Parameters:
annotationType
- the annotation type to look for- See Also:
-
equals
-
hashCode
public int hashCode() -
toString
-
findProvidedArgument
@Nullable protected static Object findProvidedArgument(MethodParameter parameter, @Nullable Object... providedArgs) -
formatArgumentError
-