Is it possible to get the method name of a java.util.function.Function. I would like to log each time the name of the method being used. The following example prints the Lambda object but I have not found an easy way to get the method name:
public class Example {
public static void main(String[] args) {
Example ex = new Example();
ex.callService(Integer::getInteger, "123");
}
private Integer callService(Function<String, Integer> sampleMethod, String input) {
Integer output = sampleMethod.apply(input);
System.out.println("Calling method "+ sampleMethod);
return output;
}
}