GroovyExpression extends AbstractExpression<T> { public T evaluate(Object target, Map<String, Object> variables) { Binding binding = new Binding(variables); binding.setVariable("target", target); synchronized (monitor) { Script script = getCompiledScript(); script.setBinding(binding); return (T) script.run(); } } GroovyExpression();  GroovyExpression(String expression);  GroovyExpression(InputStream script); T evaluate(Object target, Map<String, Object> variables); void evaluateAndSet(Object target, Object value);  }
@Test public void testExpressionFromStream() { ByteArrayInputStream in = new ByteArrayInputStream("5 + 5".getBytes()); Expression exp = new GroovyExpression(in); assertEquals(10, ((Number) exp.evaluate(null)).intValue()); }