4747import org .springframework .core .annotation .AnnotatedElementUtils ;
4848import org .springframework .core .annotation .AnnotationUtils ;
4949import org .springframework .core .annotation .SynthesizingMethodParameter ;
50+ import org .springframework .lang .Nullable ;
5051import org .springframework .objenesis .ObjenesisException ;
5152import org .springframework .objenesis .SpringObjenesis ;
5253import org .springframework .util .Assert ;
120121 * </pre>
121122 *
122123 * @author Rossen Stoyanchev
124+ * @since 5.0
123125 */
124126public class ResolvableMethod {
125127
@@ -133,7 +135,7 @@ public class ResolvableMethod {
133135
134136
135137 private ResolvableMethod (Method method ) {
136- Assert .notNull (method , "method is required" );
138+ Assert .notNull (method , "Method is required" );
137139 this .method = method ;
138140 }
139141
@@ -202,14 +204,14 @@ public final ArgResolver annotNotPresent(Class<? extends Annotation>... annotati
202204 return new ArgResolver ().annotNotPresent (annotationTypes );
203205 }
204206
205-
206207 @ Override
207208 public String toString () {
208209 return "ResolvableMethod=" + formatMethod ();
209210 }
210211
212+
211213 private String formatMethod () {
212- return (this . method ().getName () +
214+ return (method ().getName () +
213215 Arrays .stream (this .method .getParameters ())
214216 .map (this ::formatParameter )
215217 .collect (joining (",\n \t " , "(\n \t " , "\n )" )));
@@ -262,13 +264,11 @@ public static class Builder<T> {
262264
263265 private final List <Predicate <Method >> filters = new ArrayList <>(4 );
264266
265-
266267 private Builder (Class <?> objectClass ) {
267268 Assert .notNull (objectClass , "Class must not be null" );
268269 this .objectClass = objectClass ;
269270 }
270271
271-
272272 private void addFilter (String message , Predicate <Method > filter ) {
273273 this .filters .add (new LabeledPredicate <>(message , filter ));
274274 }
@@ -394,7 +394,6 @@ public ResolvableMethod mockCall(Consumer<T> invoker) {
394394 return new ResolvableMethod (method );
395395 }
396396
397-
398397 // Build & resolve shortcuts...
399398
400399 /**
@@ -448,7 +447,6 @@ public MethodParameter resolveReturnType(ResolvableType returnType) {
448447 return returning (returnType ).build ().returnType ();
449448 }
450449
451-
452450 @ Override
453451 public String toString () {
454452 return "ResolvableMethod.Builder[\n " +
@@ -462,6 +460,7 @@ private String formatFilters() {
462460 }
463461 }
464462
463+
465464 /**
466465 * Predicate with a descriptive label.
467466 */
@@ -471,7 +470,6 @@ private static class LabeledPredicate<T> implements Predicate<T> {
471470
472471 private final Predicate <T > delegate ;
473472
474-
475473 private LabeledPredicate (String label , Predicate <T > delegate ) {
476474 this .label = label ;
477475 this .delegate = delegate ;
@@ -504,14 +502,14 @@ public String toString() {
504502 }
505503 }
506504
505+
507506 /**
508507 * Resolver for method arguments.
509508 */
510509 public class ArgResolver {
511510
512511 private final List <Predicate <MethodParameter >> filters = new ArrayList <>(4 );
513512
514-
515513 @ SafeVarargs
516514 private ArgResolver (Predicate <MethodParameter >... filter ) {
517515 this .filters .addAll (Arrays .asList (filter ));
@@ -603,17 +601,18 @@ private List<MethodParameter> applyFilters() {
603601 }
604602 }
605603
604+
606605 private static class MethodInvocationInterceptor
607606 implements org .springframework .cglib .proxy .MethodInterceptor , MethodInterceptor {
608607
609608 private Method invokedMethod ;
610609
611-
612610 Method getInvokedMethod () {
613611 return this .invokedMethod ;
614612 }
615613
616614 @ Override
615+ @ Nullable
617616 public Object intercept (Object object , Method method , Object [] args , MethodProxy proxy ) {
618617 if (ReflectionUtils .isObjectMethod (method )) {
619618 return ReflectionUtils .invokeMethod (method , object , args );
@@ -625,6 +624,7 @@ public Object intercept(Object object, Method method, Object[] args, MethodProxy
625624 }
626625
627626 @ Override
627+ @ Nullable
628628 public Object invoke (org .aopalliance .intercept .MethodInvocation inv ) throws Throwable {
629629 return intercept (inv .getThis (), inv .getMethod (), inv .getArguments (), null );
630630 }
0 commit comments