'Get the callable parm function name in Java
I want to know if is possible to get the name of the class and function (or at least the function) in the callMyFunc
method below.
I need to print something like "ClsTest/myFuncInTest" or simple "myFuncInTest".
/** Main.java */
import java.util.concurrent.Callable;
public class Main
{
public static void main (String[]args) throws Exception
{
ClsTest C = new ClsTest();
callMyFunc(C::myFuncInTest);
}
private static void callMyFunc(Callable<Boolean> theFunc) throws Exception {
//System.out.println(theFunc.getName()); <-- HERE!!!!
theFunc.call();
}
}
/** ClsTest.java */
public class ClsTest {
public Boolean myFuncInTest() {
return true;
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|