For example, I want to support the following functionality:
FunctionActivator ac = new FunctionActivator();
ac.addFunc("times2", (Double x)->x*2));
ac.addFunc("reverse", (String s)-> new StringBuffer(s).reverse().toString());
Integer res = ac.useFunc("times2", 2); // should be 4
The approach I'm taking is something like that:
Interface F<R,P> {
R apply(P input);
}
Class FunctionActivator {
HashSet<String, /*don't know what to put here*/> keyToFunc;
...rest of implementation
}
If I want to keep FunctionActivator class non-generic, what type should I put in the hashset value?