@Test public void one_$parent_$and_logical_expression_returns_true_when_all_expressions_true() throws Exception { QueryExpression q = EvalTestContext.queryExpressionFromJson("{'$and': [ {'field':'field2.$parent.field3','op':'$gt','rvalue':2},{'field':'field2.$parent.field7.0.elemf1','op':'$eq','rvalue':'elvalue0_1'}]}"); QueryEvaluator qe = QueryEvaluator.getInstance(q, md); QueryEvaluationContext ctx = qe.evaluate(jsonDoc); Assert.assertTrue(ctx.getResult()); }
@Override public boolean evaluate(QueryEvaluationContext ctx) { boolean ret = false; LOGGER.debug("evaluate {}", operator); switch (operator) { case _and: ret = true; for (QueryEvaluator q : evaluators) { if (!q.evaluate(ctx)) { ret = false; break; } } break; case _or: ret = false; for (QueryEvaluator q : evaluators) { if (q.evaluate(ctx)) { ret = true; break; } } break; } ctx.setResult(ret); return ret; }
NaryLogicalExpressionEvaluator extends QueryEvaluator { @Override public boolean evaluate(QueryEvaluationContext ctx) { boolean ret = false; LOGGER.debug("evaluate {}", operator); switch (operator) { case _and: ret = true; for (QueryEvaluator q : evaluators) { if (!q.evaluate(ctx)) { ret = false; break; } } break; case _or: ret = false; for (QueryEvaluator q : evaluators) { if (q.evaluate(ctx)) { ret = true; break; } } break; } ctx.setResult(ret); return ret; } }
NaryLogicalExpressionEvaluator extends QueryEvaluator { @Override public boolean evaluate(QueryEvaluationContext ctx) { boolean ret = false; LOGGER.debug("evaluate {}", operator); switch (operator) { case _and: ret = true; for (QueryEvaluator q : evaluators) { if (!q.evaluate(ctx)) { ret = false; break; } } break; case _or: ret = false; for (QueryEvaluator q : evaluators) { if (q.evaluate(ctx)) { ret = true; break; } } break; } ctx.setResult(ret); return ret; } NaryLogicalExpressionEvaluator(NaryLogicalExpression expr,
                                          FieldTreeNode context); }
NaryLogicalExpressionEvaluator extends QueryEvaluator { @Override public boolean evaluate(QueryEvaluationContext ctx) { boolean ret = false; LOGGER.debug("evaluate {}", operator); switch (operator) { case _and: ret = true; for (QueryEvaluator q : evaluators) { if (!q.evaluate(ctx)) { ret = false; break; } } break; case _or: ret = false; for (QueryEvaluator q : evaluators) { if (q.evaluate(ctx)) { ret = true; break; } } break; } ctx.setResult(ret); return ret; } NaryLogicalExpressionEvaluator(NaryLogicalExpression expr,
                                          FieldTreeNode context); @Override boolean evaluate(QueryEvaluationContext ctx); }
NaryLogicalExpressionEvaluator extends QueryEvaluator { @Override public boolean evaluate(QueryEvaluationContext ctx) { boolean ret = false; LOGGER.debug("evaluate {}", operator); switch (operator) { case _and: ret = true; for (QueryEvaluator q : evaluators) { if (!q.evaluate(ctx)) { ret = false; break; } } break; case _or: ret = false; for (QueryEvaluator q : evaluators) { if (q.evaluate(ctx)) { ret = true; break; } } break; } ctx.setResult(ret); return ret; } NaryLogicalExpressionEvaluator(NaryLogicalExpression expr,
                                          FieldTreeNode context); @Override boolean evaluate(QueryEvaluationContext ctx);  }