I want to test if two lambda methods are equal; For example:
public class App {
@FunctionalInterface
public interface TestFunctionInterface {
void get();
}
public static void main(String[] args) throws Throwable {
TestFunctionInterface t1 = App::print1;
TestFunctionInterface t2 = App::print1;
TestFunctionInterface t3 = App::print2;
System.out.println(t1.equals(t2));
System.out.println(!t1.equals(t3));
}
private static void print1() {
}
private static void print2() {
}
}
output:
false
true
My aim is to validate that the two lambda function are the same method.
i.e. having a test that returns true.
In this way, can I get method info from the FunctionalInterface?
Thanks