/** * Traverses the children of the given appendable and manipulates it in-place. * @param parent the appendable whose children should be visited. */ protected void visitChildren(TreeAppendable parent) { for (int i = 0; i < parent.children.size(); i++) { Object o = parent.children.get(i); if (o instanceof String) { parent.children.set(i, visit((String) o)); } else { parent.children.set(i, visit((TreeAppendable) o)); } } }
public TreeAppendable acceptVisitor(TreeAppendable.Visitor visitor) { return visitor.visit(this); }
/** * Manipulate the given appendable or return a new one. * @param original the visited {@link TreeAppendable} * @return the original appendable or a new one. */ protected TreeAppendable visit(TreeAppendable original) { visitChildren(original); return original; }