I saw this example
How to convert a string to a lambda expression? expression
of how to convert a string into a java function
using this code snippet:
import java.util.function.Function;
import javax.script.*;
public class ScriptFunction {
public static void main(String[] args) throws Exception {
ScriptEngine engine = new ScriptEngineManager().getEngineByName("nashorn");
@SuppressWarnings("unchecked")
Function<Object,Object> f = (Function<Object,Object>)engine.eval(
String.format("new java.util.function.Function(%s)", args[0]));
for (int i = 1; i < args.length; i++) {
System.out.println(f.apply(args[i]));
}
}
}
In this example: it's extracting a
java.util.function.Function<Object,Object>
(in this example it a function that get a one parameter)
my question is:
it is possible to run it and get a multi Function Parameter?
how? because (java.util.function ) doesn't have this type
BiFunctionwhich accepts 2 arguments