/** * Creates a method invocation with an implicitly determined invocation type. If the method's return type derives from its declared shape, the value * is additionally casted to the value of the generically resolved method. * * @param methodDescription The method to be invoked. * @return A stack manipulation with implicitly determined invocation type. */ public static WithImplicitInvocationTargetType invoke(MethodDescription methodDescription) { MethodDescription.InDefinedShape declaredMethod = methodDescription.asDefined(); return declaredMethod.getReturnType().asErasure().equals(methodDescription.getReturnType().asErasure()) ? invoke(declaredMethod) : OfGenericMethod.of(methodDescription, invoke(declaredMethod)); }
/** * Creates a generic access dispatcher for a given method. * * @param methodDescription The generically resolved return type of the method. * @param invocation The invocation of the method in its defined shape. * @return A method access dispatcher for the given method. */ protected static WithImplicitInvocationTargetType of(MethodDescription methodDescription, WithImplicitInvocationTargetType invocation) { return new OfGenericMethod(methodDescription.getReturnType().asErasure(), invocation); }