@Test void fromReferenceToOptionalMethodWithoutClass() { Method method = MethodUtil.fromReference(TestClass::method2); assertThat(method.getName(), is("method2")); assertThat(method.getDeclaringClass().getCanonicalName(), is(TestClass.class.getCanonicalName())); }
public static <T, V> Method fromReference(Function1<T,V> methodReference) { return OptionalUtil.orGet(fromJavaFunction(methodReference), () -> fromKotlinFunction(methodReference)) .orElseThrow(() -> new RuntimeException("Failed to find writeReplace method in " + methodReference.getClass())); }
MethodUtil extends UtilityClass { public static <T, V> Method fromReference(Function1<T,V> methodReference) { return OptionalUtil.orGet(fromJavaFunction(methodReference), () -> fromKotlinFunction(methodReference)) .orElseThrow(() -> new RuntimeException("Failed to find writeReplace method in " + methodReference.getClass())); } }
MethodUtil extends UtilityClass { public static <T, V> Method fromReference(Function1<T,V> methodReference) { return OptionalUtil.orGet(fromJavaFunction(methodReference), () -> fromKotlinFunction(methodReference)) .orElseThrow(() -> new RuntimeException("Failed to find writeReplace method in " + methodReference.getClass())); }  }
MethodUtil extends UtilityClass { public static <T, V> Method fromReference(Function1<T,V> methodReference) { return OptionalUtil.orGet(fromJavaFunction(methodReference), () -> fromKotlinFunction(methodReference)) .orElseThrow(() -> new RuntimeException("Failed to find writeReplace method in " + methodReference.getClass())); }  static Object invoke(Method method, Object target, Object... args); static Stream<A> annotations(Class<A> annotationClass, Method method); static Method fromReference(Function1<T,V> methodReference); static Method fromReference(FunctionInt<T> methodReference); static Method fromReference(FunctionOptional1<T,V> methodReference); static Class<?> referringClass(Function1<T,V> methodReference); static Class<?> referringClass(FunctionInt<T> methodReference); static Class<?> referringClass(FunctionOptional1<T,V> methodReference); }
MethodUtil extends UtilityClass { public static <T, V> Method fromReference(Function1<T,V> methodReference) { return OptionalUtil.orGet(fromJavaFunction(methodReference), () -> fromKotlinFunction(methodReference)) .orElseThrow(() -> new RuntimeException("Failed to find writeReplace method in " + methodReference.getClass())); }  static Object invoke(Method method, Object target, Object... args); static Stream<A> annotations(Class<A> annotationClass, Method method); static Method fromReference(Function1<T,V> methodReference); static Method fromReference(FunctionInt<T> methodReference); static Method fromReference(FunctionOptional1<T,V> methodReference); static Class<?> referringClass(Function1<T,V> methodReference); static Class<?> referringClass(FunctionInt<T> methodReference); static Class<?> referringClass(FunctionOptional1<T,V> methodReference);  }