data.put("age", new Long(25));
data.put("licenseToKill", Boolean.TRUE);
Expression expr = filter.buildExpression(data);
// evaluate expression in memory
Object value = expr.evaluate(new VariableResolver() {
public Object resolve(Variable variable) {
if (variable.getName().equals("name")) {
return "James Bond";
}
if (variable.getName().equals("age")) {
return new Long(30);
}
if (variable.getName().equals("licenseToKill")) {
return Boolean.TRUE;
}
return null;
}
});
assertEquals(value, Boolean.TRUE);
// evaluate expression in memory
value = expr.evaluate(new VariableResolver() {
public Object resolve(Variable variable) {
if (variable.getName().equals("name")) {
return "Bond, James";
}
return null;
}
});
assertEquals(value, Boolean.FALSE);
// build sql expression
StandardExpressionToSqlExprBuilder builder = new StandardExpressionToSqlExprBuilder();
builder.setMapper(new VariableResolver() {
public Object resolve(Variable variable) {
if ("name".equals(variable.getName())) {
return "AGENT.NAME";
}
if ("age".equals(variable.getName())) {