/** * Matches an iteration of generic types' erasures against the provided types. As a wildcard does not define an erasure, a runtime * exception is thrown when this matcher is applied to a wildcard. * * @param type The types to match. * @param <T> The type of the matched object. * @return A matcher that matches an iteration of generic types' raw types against the provided non-generic types. */ public static <T extends Iterable<? extends TypeDescription.Generic>> ElementMatcher.Junction<T> erasures(TypeDescription... type) { return erasures(Arrays.asList(type)); }
/** * Matches a method description that takes the provided raw arguments. * * @param type The arguments to match against the matched method. * @param <T> The type of the matched object. * @return A method matcher that matches a method's raw parameter types against the supplied arguments. */ public static <T extends MethodDescription> ElementMatcher.Junction<T> takesArguments(Class<?>... type) { return takesGenericArguments(erasures(type)); }
/** * Matches an iteration of generic types' erasures against the provided types. As a wildcard does not define an erasure, a runtime * exception is thrown when this matcher is applied to a wildcard. * * @param type The types to match. * @param <T> The type of the matched object. * @return A matcher that matches an iteration of generic types' raw types against the provided non-generic types. */ public static <T extends Iterable<? extends TypeDescription.Generic>> ElementMatcher.Junction<T> erasures(Class<?>... type) { return erasures(new TypeList.ForLoadedTypes(type)); }
/** * Matches a method description that takes the provided raw arguments. * * @param type The arguments to match against the matched method. * @param <T> The type of the matched object. * @return A method matcher that matches a method's raw parameter types against the supplied arguments. */ public static <T extends MethodDescription> ElementMatcher.Junction<T> takesArguments(TypeDescription... type) { return takesGenericArguments(erasures(type)); }
/** * Matches an iteration of generic types' erasures against the provided types. As a wildcard does not define an erasure, a runtime * exception is thrown when this matcher is applied to a wildcard. * * @param types The types to match. * @param <T> The type of the matched object. * @return A matcher that matches an iteration of generic types' raw types against the provided non-generic types. */ public static <T extends Iterable<? extends TypeDescription.Generic>> ElementMatcher.Junction<T> erasures( Iterable<? extends TypeDescription> types) { List<ElementMatcher<? super TypeDescription>> typeMatchers = new ArrayList<ElementMatcher<? super TypeDescription>>(); for (TypeDescription type : types) { typeMatchers.add(is(type)); } return erasures(new CollectionOneToOneMatcher<TypeDescription>(typeMatchers)); }
/** * 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))); }