A Java library for dynamic parsing, creation and loading of functions from Strings. Javadoc
ParsedFunction function = FunctionParser.fromString("boolean(Integer x,y)-> x > y");
System.out.println(function.evaluateToBoolean(new Integer[]{2, 3}));
ParsedFunction<Point> func = FunctionParser.fromString("java.awt.Point(java.awt.Point a,b)->return new java.awt.Point(a.x + b.x,a.y + b.y);");
Object[] args = {new Point(3, 5), new Point(5, 2)};
Point result = func.evaluate(args);
System.out.println(result);
ParsedFunction function = FunctionParser.fromString("double(java.util.List l)->double tot = 0; for(java.util.Iterator iterator = ((java.util.List) l).iterator(); iterator.hasNext(); ){ Object o = iterator.next(); tot+=((Double)o).doubleValue();} return tot;");
Object[] args = new Object[]{Arrays.asList(1.0,2.0,3.0,4.0,5.0)};
System.out.println(function.evaluateToDouble(args));
<dependency>
<groupId>com.github.alfredvc</groupId>
<artifactId>FunctionParser</artifactId>
<version>0.13-SNAPSHOT</version>
</dependency>
No form of safety checking is done on the input string, so it is up to the user to verify that no dangerous functions are being compiled.