/** * Matches {@link MethodDescription}s that returns a given * {@link TypeDescription}. * * @param type The type the matched method is expected to return. * @param <T> The type of the matched object. * @return An element matcher that matches a given return type for a method description. */ public static <T extends MethodDescription> ElementMatcher.Junction<T> returnsGeneric(TypeDescription.Generic type) { return returnsGeneric(is(type)); }
/** * Matches {@link MethodDescription}s that return a given generic type. * * @param type The generic type the matched method is expected to return. * @param <T> The type of the matched object. * @return An element matcher that matches a given generic return type for a method description. */ public static <T extends MethodDescription> ElementMatcher.Junction<T> returnsGeneric(Type type) { return returnsGeneric(TypeDefinition.Sort.describe(type)); }
/** * Matches a method's return type's erasure by the given matcher. * * @param matcher The matcher to apply to a method's return type's erasure. * @param <T> The type of the matched object. * @return A matcher that matches the matched method's return type's erasure. */ public static <T extends MethodDescription> ElementMatcher.Junction<T> returns(ElementMatcher<? super TypeDescription> matcher) { return returnsGeneric(erasure(matcher)); }
/** * Matches {@link MethodDescription}s that return a given erasure type. * * @param type The raw type the matched method is expected to return. * @param <T> The type of the matched object. * @return An element matcher that matches a given return type for a method description. */ public static <T extends MethodDescription> ElementMatcher.Junction<T> returns(Class<?> type) { return returnsGeneric(erasure(type)); }
/** * Matches any Java bean getter method which returns an value with a type matches the supplied matcher. * * @param matcher A matcher to be allied to a getter method's argument type. * @param <T> The type of the matched object. * @return A matcher that matches a getter method with a return type that matches the supplied matcher. */ public static <T extends MethodDescription> ElementMatcher.Junction<T> isGenericGetter(ElementMatcher<? super TypeDescription.Generic> matcher) { return isGetter().and(returnsGeneric(matcher)); }
/** * Matches any Java bean getter method. * * @param <T> The type of the matched object. * @return A matcher that matches any getter method. */ public static <T extends MethodDescription> ElementMatcher.Junction<T> isGetter() { return takesArguments(0).and(not(returns(TypeDescription.VOID))).and(nameStartsWith("get").or(nameStartsWith("is").and(returnsGeneric(anyOf(boolean.class, Boolean.class))))); }