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
Nested ClassesModifier and TypeClassDescriptionprotected classA MethodParameter with AnnotatedMethod-specific behavior. -
Constructor Summary
ConstructorsModifierConstructorDescriptionAnnotatedMethod(Method method) Create an instance that wraps the givenMethod.protectedAnnotatedMethod(AnnotatedMethod annotatedMethod) Copy constructor for use in subclasses. -
Method Summary
Modifier and TypeMethodDescriptionbooleanprotected static ObjectfindProvidedArgument(MethodParameter parameter, Object... providedArgs) protected static StringformatArgumentError(MethodParameter param, String message) protected final MethodIf 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 MethodReturn 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 aMethodParameterfor the declared return type.getReturnValueType(Object returnValue) Return aMethodParameterfor the actual return value type.inthashCode()<A extends Annotation>
booleanhasMethodAnnotation(Class<A> annotationType) Determine if an annotation of the given type is present or meta-present on the method.booleanisVoid()Returntrueif the method's return type is void,falseotherwise.toString()
-
Constructor Details
-
AnnotatedMethod
Create an instance that wraps the givenMethod.- Parameters:
method- theMethodhandle 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 aMethodParameterfor the declared return type. -
getReturnValueType
Return aMethodParameterfor the actual return value type. -
isVoid
public boolean isVoid()Returntrueif the method's return type is void,falseotherwise. -
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
nullif 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
-