@PublicApi public class NodeTraverser extends Object
Node
tree.Modifier and Type | Class and Description |
---|---|
static class |
NodeTraverser.LeaveOrEnter
Used to indicate via
TraverserContext.getVar(Class) if the visit happens inside the ENTER or LEAVE phase. |
Constructor and Description |
---|
NodeTraverser() |
NodeTraverser(Map<Class<?>,Object> rootVars,
Function<? super Node,? extends List<Node>> getChildren) |
Modifier and Type | Method and Description |
---|---|
Object |
depthFirst(NodeVisitor nodeVisitor,
Collection<? extends Node> roots)
depthFirst traversal with a enter/leave phase.
|
Object |
depthFirst(NodeVisitor nodeVisitor,
Node root)
depthFirst traversal with a enter/leave phase.
|
static <T> T |
oneVisitWithResult(Node node,
NodeVisitor nodeVisitor) |
Object |
postOrder(NodeVisitor nodeVisitor,
Collection<? extends Node> roots)
Post-Order traversal: This is a specialized version of depthFirst with only the leave phase.
|
Object |
postOrder(NodeVisitor nodeVisitor,
Node root)
Version of
postOrder(NodeVisitor, Collection) with one root. |
Object |
preOrder(NodeVisitor nodeVisitor,
Collection<? extends Node> roots)
Pre-Order traversal: This is a specialized version of depthFirst with only the enter phase.
|
Object |
preOrder(NodeVisitor nodeVisitor,
Node root)
Version of
preOrder(NodeVisitor, Collection) with one root. |
public NodeTraverser(Map<Class<?>,Object> rootVars, Function<? super Node,? extends List<Node>> getChildren)
public NodeTraverser()
public Object depthFirst(NodeVisitor nodeVisitor, Node root)
nodeVisitor
- the visitor of the nodesroot
- the root nodepublic Object depthFirst(NodeVisitor nodeVisitor, Collection<? extends Node> roots)
nodeVisitor
- the visitor of the nodesroots
- the root nodespublic Object preOrder(NodeVisitor nodeVisitor, Node root)
preOrder(NodeVisitor, Collection)
with one root.nodeVisitor
- the visitor of the nodesroot
- the root nodepublic Object preOrder(NodeVisitor nodeVisitor, Collection<? extends Node> roots)
nodeVisitor
- the visitor of the nodesroots
- the root nodespublic Object postOrder(NodeVisitor nodeVisitor, Node root)
postOrder(NodeVisitor, Collection)
with one root.nodeVisitor
- the visitor of the nodesroot
- the root nodepublic Object postOrder(NodeVisitor nodeVisitor, Collection<? extends Node> roots)
nodeVisitor
- the visitor of the nodesroots
- the root nodespublic static <T> T oneVisitWithResult(Node node, NodeVisitor nodeVisitor)
Copyright © 2019. All rights reserved.