/** * Matches a {@link MethodDescription} by validating that its parameters * fulfill a given constraint. * * @param matcher The matcher to apply for validating the parameters. * @param <T> The type of the matched object. * @return A matcher that matches a method description's parameters against the given constraint. */ public static <T extends MethodDescription> ElementMatcher.Junction<T> hasParameters( ElementMatcher<? super Iterable<? extends ParameterDescription>> matcher) { return new MethodParametersMatcher<T>(matcher); }
/** * Matches a {@link MethodDescription} by applying an iterable collection of element matcher on any parameter's {@link TypeDescription.Generic}. * * @param matchers The matcher that are applied onto the parameter types of the matched method description. * @param <T> The type of the matched object. * @return A matcher that matches a method description by applying another element matcher onto each parameter's type. */ public static <T extends MethodDescription> ElementMatcher.Junction<T> takesGenericArguments(ElementMatcher<? super Iterable<? extends TypeDescription.Generic>> matchers) { return new MethodParametersMatcher<T>(new MethodParameterTypesMatcher<ParameterList<?>>(matchers)); }
/** * Matches a {@link MethodDescription} by the number of its parameters. * * @param length The expected length. * @param <T> The type of the matched object. * @return A matcher that matches a method description by the number of its parameters. */ public static <T extends MethodDescription> ElementMatcher.Junction<T> takesArguments(int length) { return new MethodParametersMatcher<T>(new CollectionSizeMatcher<ParameterList<?>>(length)); }
/** * Matches a {@link MethodDescription} by applying an iterable collection of element matcher on any parameter's {@link TypeDescription}. * * @param matchers The matcher that are applied onto the parameter types of the matched method description. * @param <T> The type of the matched object. * @return A matcher that matches a method description by applying another element matcher onto each parameter's type. */ public static <T extends MethodDescription> ElementMatcher.Junction<T> takesArguments(ElementMatcher<? super Iterable<? extends TypeDescription>> matchers) { return new MethodParametersMatcher<T>(new MethodParameterTypesMatcher<ParameterList<?>>(erasures(matchers))); }