/** * Get the result of the rewrite. * * @return the resulting operator */ public Op getResult() { if (result.size() == 0) { return OpNull.create(); } if (result.size() == 1) { return result.get(0); } return result; }
/** Rewrite sequence elements */ @Override public void visit(final OpSequence opSequence) { if (LOG.isDebugEnabled()) { LOG.debug("Starting visiting OpSequence"); } addOp(rewriteOpN(opSequence, OpSequence.create())); }
private static Op flush(BasicPattern pattern, Op op) { if (pattern == null || pattern.isEmpty()) { if (op == null) return OpTable.unit(); return op; } OpBGP opBGP = new OpBGP(pattern); return OpSequence.create(op, opBGP); }
/** * Add the operation to the result. * * @param op the operation to add. */ private void addOp(final Op op) { result.add(op); }
/** * Reset the rewriter to the initial state. * * @return this rewriter for chaining. */ public OpRewriter reset() { result = OpSequence.create(); return this; }