Package graphql.language
Class NodeTraverser
- java.lang.Object
-
- graphql.language.NodeTraverser
-
@PublicApi public class NodeTraverser extends java.lang.Object
Lets you traverse aNodetree.
-
-
Constructor Summary
Constructors Constructor Description NodeTraverser()NodeTraverser(java.util.Map<java.lang.Class<?>,java.lang.Object> rootVars, java.util.function.Function<? super Node,? extends java.util.List<Node>> getChildren)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.ObjectdepthFirst(NodeVisitor nodeVisitor, Node root)depthFirst traversal with a enter/leave phase.java.lang.ObjectdepthFirst(NodeVisitor nodeVisitor, java.util.Collection<? extends Node> roots)depthFirst traversal with a enter/leave phase.static <T> ToneVisitWithResult(Node node, NodeVisitor nodeVisitor)java.lang.ObjectpostOrder(NodeVisitor nodeVisitor, Node root)Version ofpostOrder(NodeVisitor, Collection)with one root.java.lang.ObjectpostOrder(NodeVisitor nodeVisitor, java.util.Collection<? extends Node> roots)Post-Order traversal: This is a specialized version of depthFirst with only the leave phase.java.lang.ObjectpreOrder(NodeVisitor nodeVisitor, Node root)Version ofpreOrder(NodeVisitor, Collection)with one root.java.lang.ObjectpreOrder(NodeVisitor nodeVisitor, java.util.Collection<? extends Node> roots)Pre-Order traversal: This is a specialized version of depthFirst with only the enter phase.
-
-
-
Method Detail
-
depthFirst
public java.lang.Object depthFirst(NodeVisitor nodeVisitor, Node root)
depthFirst traversal with a enter/leave phase.- Parameters:
nodeVisitor- the visitor of the nodesroot- the root node- Returns:
- the accumulation result of this traversal
-
depthFirst
public java.lang.Object depthFirst(NodeVisitor nodeVisitor, java.util.Collection<? extends Node> roots)
depthFirst traversal with a enter/leave phase.- Parameters:
nodeVisitor- the visitor of the nodesroots- the root nodes- Returns:
- the accumulation result of this traversal
-
preOrder
public java.lang.Object preOrder(NodeVisitor nodeVisitor, Node root)
Version ofpreOrder(NodeVisitor, Collection)with one root.- Parameters:
nodeVisitor- the visitor of the nodesroot- the root node- Returns:
- the accumulation result of this traversal
-
preOrder
public java.lang.Object preOrder(NodeVisitor nodeVisitor, java.util.Collection<? extends Node> roots)
Pre-Order traversal: This is a specialized version of depthFirst with only the enter phase.- Parameters:
nodeVisitor- the visitor of the nodesroots- the root nodes- Returns:
- the accumulation result of this traversal
-
postOrder
public java.lang.Object postOrder(NodeVisitor nodeVisitor, Node root)
Version ofpostOrder(NodeVisitor, Collection)with one root.- Parameters:
nodeVisitor- the visitor of the nodesroot- the root node- Returns:
- the accumulation result of this traversal
-
postOrder
public java.lang.Object postOrder(NodeVisitor nodeVisitor, java.util.Collection<? extends Node> roots)
Post-Order traversal: This is a specialized version of depthFirst with only the leave phase.- Parameters:
nodeVisitor- the visitor of the nodesroots- the root nodes- Returns:
- the accumulation result of this traversal
-
oneVisitWithResult
public static <T> T oneVisitWithResult(Node node, NodeVisitor nodeVisitor)
-
-