public static <T> Supplier<T> method( Type<T> returnType, Method factory, Object instance, Parameter<?>... parameters) { if (!Type.returnType(factory).isAssignableTo(returnType)) { throw new IllegalArgumentException( "The factory methods methods return type `" + Type.returnType(factory) + "` is not assignable to: " + returnType); } if (instance != null && factory.getDeclaringClass() != instance.getClass()) { throw new IllegalArgumentException( "The factory method and the instance it is invoked on have to be the same class."); } Argument<?>[] arguments = Argument.arguments(Type.parameterTypes(factory), parameters); return new FactoryMethodSupplier<T>(returnType, factory, instance, arguments); }