ExpressionEvaluatorImpl implements ExpressionEvaluator { private boolean evaluateBinaryBooleanExpression(BinaryBooleanExpression binaryBooleanExpression, DataRow dataRow) { boolean left = evaluateAsOrDefault(binaryBooleanExpression.getLeft(), dataRow, Boolean.class, false); boolean right = evaluateAsOrDefault(binaryBooleanExpression.getRight(), dataRow, Boolean.class, false); switch (binaryBooleanExpression.getBinaryBooleanOperator()) { default: case AND: return left && right; case OR: return left || right; case XOR: return left ^ right; } }  @Override Map<String, Set<String>> getColumnNames(Object expression); @Override T evaluate(Object expression, DataRow dataRow); @Override T evaluateAs(Object expression, DataRow dataRow, Class<T> cls);  }
@Test public void testEvaluateBinaryBooleanExpression() { final SimpleBooleanExpression TRUTHY = new SimpleBooleanExpression(1, EQUAL, 1); final SimpleBooleanExpression FALSY = new SimpleBooleanExpression(1, NOT_EQUAL, 1); assertThat(bool(TRUTHY, AND, TRUTHY), is(true)); assertThat(bool(TRUTHY, AND, FALSY), is(false)); assertThat(bool(FALSY, AND, TRUTHY), is(false)); assertThat(bool(FALSY, AND, FALSY), is(false)); assertThat(bool(TRUTHY, OR, TRUTHY), is(true)); assertThat(bool(TRUTHY, OR, FALSY), is(true)); assertThat(bool(FALSY, OR, TRUTHY), is(true)); assertThat(bool(FALSY, OR, FALSY), is(false)); assertThat(bool(TRUTHY, XOR, TRUTHY), is(false)); assertThat(bool(TRUTHY, XOR, FALSY), is(true)); assertThat(bool(FALSY, XOR, TRUTHY), is(true)); assertThat(bool(FALSY, XOR, FALSY), is(false)); }