@Test public void testPrecondition() throws Exception { Row row = new Row("a", 1).add("b", "x").add("c", 2.06); Assert.assertEquals(true, new Precondition("a == 1 && b == \"x\"").apply(row)); Assert.assertEquals(true, new Precondition("c > 2.0").apply(row)); Assert.assertEquals(true, new Precondition("true").apply(row)); Assert.assertEquals(false, new Precondition("false").apply(row)); }
public Precondition(String condition) throws PreconditionException { this.condition = condition; JexlScriptEngine engine = new JexlScriptEngine(); try { script = engine.compile(condition); } catch (ScriptException e) { if (e.getCause() != null) { throw new PreconditionException(e.getCause().getMessage()); } else { throw new PreconditionException(e.getMessage()); } } }
Precondition { public Precondition(String condition) throws PreconditionException { this.condition = condition; JexlScriptEngine engine = new JexlScriptEngine(); try { script = engine.compile(condition); } catch (ScriptException e) { if (e.getCause() != null) { throw new PreconditionException(e.getCause().getMessage()); } else { throw new PreconditionException(e.getMessage()); } } } }
Precondition { public Precondition(String condition) throws PreconditionException { this.condition = condition; JexlScriptEngine engine = new JexlScriptEngine(); try { script = engine.compile(condition); } catch (ScriptException e) { if (e.getCause() != null) { throw new PreconditionException(e.getCause().getMessage()); } else { throw new PreconditionException(e.getMessage()); } } } Precondition(String condition); }
Precondition { public Precondition(String condition) throws PreconditionException { this.condition = condition; JexlScriptEngine engine = new JexlScriptEngine(); try { script = engine.compile(condition); } catch (ScriptException e) { if (e.getCause() != null) { throw new PreconditionException(e.getCause().getMessage()); } else { throw new PreconditionException(e.getMessage()); } } } Precondition(String condition); boolean apply(Row row); }
Precondition { public Precondition(String condition) throws PreconditionException { this.condition = condition; JexlScriptEngine engine = new JexlScriptEngine(); try { script = engine.compile(condition); } catch (ScriptException e) { if (e.getCause() != null) { throw new PreconditionException(e.getCause().getMessage()); } else { throw new PreconditionException(e.getMessage()); } } } Precondition(String condition); boolean apply(Row row);  }