Package org.springframework.core.annotation

# Class AnnotatedMethod

java.lang.Object
org.springframework.core.annotation.AnnotatedMethod

public class AnnotatedMethod extends Object
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, Sam Brannen
See Also:
  - `getMethodAnnotation(Class)`
  - `getMethodParameters()`
  - `AnnotatedElementUtils`
  - `SynthesizingMethodParameter`

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`protected class`
`AnnotatedMethod.AnnotatedMethodParameter`
A MethodParameter with AnnotatedMethod-specific behavior.

## Constructor Summary

Constructors
Modifier
Constructor
Description
``
`AnnotatedMethod(Method method)`
Create an instance that wraps the given `Method`.
`protected`
`AnnotatedMethod(AnnotatedMethod annotatedMethod)`
Copy constructor for use in subclasses.

## Method Summary

Modifier and Type
Method
Description
`boolean`
`equals(Object other)`
`protected static Object`
`findProvidedArgument(MethodParameter parameter, Object... providedArgs)`
`protected static String`
`formatArgumentError(MethodParameter param, String message)`
`protected final Method`
`getBridgedMethod()`
If the annotated method is a bridge method, this method returns the bridged (user-defined) method.
`protected Class<?>`
`getContainingClass()`
Expose the containing class for method parameters.
`final Method`
`getMethod()`
Return the annotated method.
`<A extends Annotation>
A`
`getMethodAnnotation(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[]`
`getMethodParameters()`
Return the method parameters for this `AnnotatedMethod`.
`MethodParameter`
`getReturnType()`
Return a `MethodParameter` for the declared return type.
`MethodParameter`
`getReturnValueType(Object returnValue)`
Return a `MethodParameter` for the actual return value type.
`int`
`hashCode()`
`<A extends Annotation>
boolean`
`hasMethodAnnotation(Class<A> annotationType)`
Determine if an annotation of the given type is present or meta-present on the method.
`boolean`
`isVoid()`
Return `true` if the method's return type is void, `false` otherwise.
`String`
`toString()`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

## Constructor Details

### AnnotatedMethod

public AnnotatedMethod(Method method)
Create an instance that wraps the given `Method`.

Parameters:
  `method` - the `Method` handle to wrap

### AnnotatedMethod

protected AnnotatedMethod(AnnotatedMethod annotatedMethod)
Copy constructor for use in subclasses.

## Method Details

### getMethod

public final Method getMethod()
Return the annotated method.

### getBridgedMethod

protected final Method getBridgedMethod()
If the annotated method is a bridge method, this method returns the bridged (user-defined) method. Otherwise, it returns the same method as `getMethod()`.

### getContainingClass

protected Class<?> getContainingClass()
Expose the containing class for method parameters.

See Also:
  - `MethodParameter.getContainingClass()`

### getMethodParameters

public final MethodParameter[] getMethodParameters()
Return the method parameters for this `AnnotatedMethod`.

### getReturnType

public MethodParameter getReturnType()
Return a `MethodParameter` for the declared return type.

### getReturnValueType

public MethodParameter getReturnValueType(@Nullable Object returnValue)
Return a `MethodParameter` for the actual return value type.

### isVoid

public boolean isVoid()
Return `true` if the method's return type is void, `false` otherwise.

### getMethodAnnotation

@Nullable public <A extends Annotation> A getMethodAnnotation(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.

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:
  - `AnnotatedElementUtils.findMergedAnnotation(java.lang.reflect.AnnotatedElement, java.lang.Class<A>)`

### hasMethodAnnotation

public <A extends Annotation> boolean hasMethodAnnotation(Class<A> annotationType)
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:
  - `AnnotatedElementUtils.hasAnnotation(java.lang.reflect.AnnotatedElement, java.lang.Class<? extends java.lang.annotation.Annotation>)`

### equals

public boolean equals(@Nullable Object other)

Overrides:
  `equals` in class `Object`

### hashCode

public int hashCode()

Overrides:
  `hashCode` in class `Object`

### toString

public String toString()

Overrides:
  `toString` in class `Object`

### findProvidedArgument

@Nullable protected static Object findProvidedArgument(MethodParameter parameter, @Nullable Object... providedArgs)

### formatArgumentError

protected static String formatArgumentError(MethodParameter param, String message)