Browse Source

Polish AnnotatedMethod

pull/30825/head
Sam Brannen 3 years ago
parent
commit
d0a2820af4
  1. 27
      spring-core/src/main/java/org/springframework/core/annotation/AnnotatedMethod.java

27
spring-core/src/main/java/org/springframework/core/annotation/AnnotatedMethod.java

@ -59,7 +59,7 @@ public class AnnotatedMethod {
/** /**
* Create an instance that wraps the given {@link Method}. * Create an instance that wraps the given {@link Method}.
* @param method the Method handle to wrap * @param method the {@code Method} handle to wrap
*/ */
public AnnotatedMethod(Method method) { public AnnotatedMethod(Method method) {
Assert.notNull(method, "Method is required"); Assert.notNull(method, "Method is required");
@ -82,14 +82,14 @@ public class AnnotatedMethod {
/** /**
* Return the method for this handler method. * Return the annotated method.
*/ */
public final Method getMethod() { public final Method getMethod() {
return this.method; return this.method;
} }
/** /**
* If the bean method is a bridge method, this method returns the bridged * If the annotated method is a bridge method, this method returns the bridged
* (user-defined) method. Otherwise, it returns the same method as {@link #getMethod()}. * (user-defined) method. Otherwise, it returns the same method as {@link #getMethod()}.
*/ */
protected final Method getBridgedMethod() { protected final Method getBridgedMethod() {
@ -105,7 +105,7 @@ public class AnnotatedMethod {
} }
/** /**
* Return the method parameters for this handler method. * Return the method parameters for this {@code AnnotatedMethod}.
*/ */
public final MethodParameter[] getMethodParameters() { public final MethodParameter[] getMethodParameters() {
return this.parameters; return this.parameters;
@ -121,32 +121,31 @@ public class AnnotatedMethod {
} }
/** /**
* Return a MethodParameter for the declared return type. * Return a {@link MethodParameter} for the declared return type.
*/ */
public MethodParameter getReturnType() { public MethodParameter getReturnType() {
return new AnnotatedMethodParameter(-1); return new AnnotatedMethodParameter(-1);
} }
/** /**
* Return a MethodParameter for the actual return value type. * Return a {@link MethodParameter} for the actual return value type.
*/ */
public MethodParameter getReturnValueType(@Nullable Object returnValue) { public MethodParameter getReturnValueType(@Nullable Object returnValue) {
return new ReturnValueMethodParameter(returnValue); return new ReturnValueMethodParameter(returnValue);
} }
/** /**
* Return {@code true} if the method return type is void, {@code false} otherwise. * Return {@code true} if the method's return type is void, {@code false} otherwise.
*/ */
public boolean isVoid() { public boolean isVoid() {
return Void.TYPE.equals(getReturnType().getParameterType()); return Void.TYPE.equals(getReturnType().getParameterType());
} }
/** /**
* Return a single annotation on the underlying method traversing its super methods * Return a single annotation on the underlying method, traversing its super methods
* if no annotation can be found on the given method itself. * if no annotation can be found on the given method itself.
* <p>Also supports <em>merged</em> composed annotations with attribute * <p>Supports <em>merged</em> composed annotations with attribute overrides.
* overrides as of Spring Framework 4.2.2. * @param annotationType the annotation type to look for
* @param annotationType the type of annotation to introspect the method for
* @return the annotation, or {@code null} if none found * @return the annotation, or {@code null} if none found
* @see AnnotatedElementUtils#findMergedAnnotation * @see AnnotatedElementUtils#findMergedAnnotation
*/ */
@ -156,9 +155,9 @@ public class AnnotatedMethod {
} }
/** /**
* Return whether the parameter is declared with the given annotation type. * Determine if an annotation of the given type is <em>present</em> or
* <em>meta-present</em> on the method.
* @param annotationType the annotation type to look for * @param annotationType the annotation type to look for
* @since 4.3
* @see AnnotatedElementUtils#hasAnnotation * @see AnnotatedElementUtils#hasAnnotation
*/ */
public <A extends Annotation> boolean hasMethodAnnotation(Class<A> annotationType) { public <A extends Annotation> boolean hasMethodAnnotation(Class<A> annotationType) {
@ -208,7 +207,7 @@ public class AnnotatedMethod {
@Override @Override
public int hashCode() { public int hashCode() {
return (this.method.hashCode()); return this.method.hashCode();
} }
@Override @Override

Loading…
Cancel
Save