@Override public QueryExpression iterate(QueryExpression q, Path context) { // Don't send classes the base iterator doesn't recognize if (q instanceof TruePH || q instanceof FalsePH) { return q; } else { return super.iterate(q, context); } }
@Override protected QueryExpression itrNaryLogicalExpression(NaryLogicalExpression q, Path context) { return super.itrNaryLogicalExpression(q, context); }
@Override protected QueryExpression itrUnaryLogicalExpression(UnaryLogicalExpression q, Path context) { return super.itrUnaryLogicalExpression(q, context); }
@Override protected QueryExpression itrArrayMatchExpression(ArrayMatchExpression q, Path context) { fieldInfo.add(resolveField(q.getArray(), context, q, false)); return super.itrArrayMatchExpression(q, context); }
@Override protected QueryExpression itrArrayMatchExpression(ArrayMatchExpression q, Path context) { fieldInfo.add(resolveField(q.getArray(), context, q, false)); return super.itrArrayMatchExpression(q, context); }
@Override public QueryExpression iterate(QueryExpression q, Path context) { // Don't send classes the base iterator doesn't recognize if (q instanceof TruePH || q instanceof FalsePH) { return q; } else { return super.iterate(q, context); } }
@Override protected QueryExpression itrArrayMatchExpression(ArrayMatchExpression q, Path context) { ArrayMatchExpression x = (ArrayMatchExpression) super.itrArrayMatchExpression(q, context); Path p = map(applyContext(context, x.getArray())); if (p != null) { return new ArrayMatchExpression(removeContext(context, p, x.getArray()), x.getElemMatch()); } else { return x; } }
@Override protected QueryExpression itrNaryLogicalExpression(NaryLogicalExpression q, Path context) { return super.itrNaryLogicalExpression(q, context); }
@Override protected QueryExpression itrUnaryLogicalExpression(UnaryLogicalExpression q, Path context) { return super.itrUnaryLogicalExpression(q, context); }
@Override public QueryExpression iterate(QueryExpression q, Path context) { if (nested == 0) { fieldInfo = new ArrayList<>(); } nested++; try { return super.iterate(q, context); } finally { nested--; } }
@Override protected QueryExpression itrArrayMatchExpression(ArrayMatchExpression q, Path context) { ArrayMatchExpression x = (ArrayMatchExpression) super.itrArrayMatchExpression(q, context); Path p = map(applyContext(context, x.getArray())); if (p != null) { return new ArrayMatchExpression(removeContext(context, p, x.getArray()), x.getElemMatch()); } else { return x; } }
NaryLogicalExpression nq = (NaryLogicalExpression) super.itrNaryLogicalExpression(q, context); CopyOnWriteIterator<QueryExpression> itr = new CopyOnWriteIterator<QueryExpression>(nq.getQueries()); while (itr.hasNext()) {
/** * If the enclosed query is a placeholder (TruePH or FalsePH), it * negates the placeholder, otherwise, the query remains as is */ @Override protected QueryExpression itrUnaryLogicalExpression(UnaryLogicalExpression q, Path context) { UnaryLogicalExpression nq = (UnaryLogicalExpression) super.itrUnaryLogicalExpression(q, context); if (nq.getQuery() instanceof TruePH) { return new FalsePH(); } else if (nq.getQuery() instanceof FalsePH) { return new TruePH(); } else { return nq; } }
@Override public QueryExpression iterate(QueryExpression q, Path context) { if (nested == 0) { fieldInfo = new ArrayList<>(); } nested++; try { return super.iterate(q, context); } finally { nested--; } }
NaryLogicalExpression nq = (NaryLogicalExpression) super.itrNaryLogicalExpression(q, context); CopyOnWriteIterator<QueryExpression> itr = new CopyOnWriteIterator<QueryExpression>(nq.getQueries()); while (itr.hasNext()) {
/** * If the enclosed query is a placeholder (TruePH or FalsePH), it * negates the placeholder, otherwise, the query remains as is */ @Override protected QueryExpression itrUnaryLogicalExpression(UnaryLogicalExpression q, Path context) { UnaryLogicalExpression nq = (UnaryLogicalExpression) super.itrUnaryLogicalExpression(q, context); if (nq.getQuery() instanceof TruePH) { return new FalsePH(); } else if (nq.getQuery() instanceof FalsePH) { return new TruePH(); } else { return nq; } }
/** * Default behavior is to recursively iterate the nested query. If nested * processing returns an object different from the original nested query, * this method creates a new unary logical expression using the new query * expression, and returns that. */ protected QueryExpression itrUnaryLogicalExpression(UnaryLogicalExpression q, Path context) { QueryExpression newq = iterate(q.getQuery(), context); if (newq != q.getQuery()) { return new UnaryLogicalExpression(q.getOp(), newq); } else { return q; } }
/** * Default behavior is to recursively iterate the nested query. If nested * processing returns an object different from the original nested query, * this method creates a new unary logical expression using the new query * expression, and returns that. */ protected QueryExpression itrUnaryLogicalExpression(UnaryLogicalExpression q, Path context) { QueryExpression newq = iterate(q.getQuery(), context); if (newq != q.getQuery()) { return new UnaryLogicalExpression(q.getOp(), newq); } else { return q; } }
/** * Default behavior is to recursively iterate the nested query. If nested * processing returns an object different from the original nested query, * this method creates a new array match expression using the new query * expression, and returns that. */ protected QueryExpression itrArrayMatchExpression(ArrayMatchExpression q, Path context) { QueryExpression newq = iterate(q.getElemMatch(), new Path(new Path(context, q.getArray()), Path.ANYPATH)); if (newq != q.getElemMatch()) { return new ArrayMatchExpression(q.getArray(), newq); } else { return q; } } }
/** * Default behavior is to recursively iterate the nested query. If nested * processing returns an object different from the original nested query, * this method creates a new array match expression using the new query * expression, and returns that. */ protected QueryExpression itrArrayMatchExpression(ArrayMatchExpression q, Path context) { QueryExpression newq = iterate(q.getElemMatch(), new Path(new Path(context, q.getArray()), Path.ANYPATH)); if (newq != q.getElemMatch()) { return new ArrayMatchExpression(q.getArray(), newq); } else { return q; } } }