Class NodeTraverser

java.lang.Object
graphql.language.NodeTraverser

@PublicApi public class NodeTraverser extends Object
Lets you traverse a Node tree.
  • Constructor Details

  • Method Details

    • depthFirst

      public Object depthFirst(NodeVisitor nodeVisitor, Node root)
      depthFirst traversal with a enter/leave phase.
      Parameters:
      nodeVisitor - the visitor of the nodes
      root - the root node
      Returns:
      the accumulation result of this traversal
    • depthFirst

      public Object depthFirst(NodeVisitor nodeVisitor, Collection<? extends Node> roots)
      depthFirst traversal with a enter/leave phase.
      Parameters:
      nodeVisitor - the visitor of the nodes
      roots - the root nodes
      Returns:
      the accumulation result of this traversal
    • preOrder

      public Object preOrder(NodeVisitor nodeVisitor, Node root)
      Version of preOrder(NodeVisitor, Collection) with one root.
      Parameters:
      nodeVisitor - the visitor of the nodes
      root - the root node
      Returns:
      the accumulation result of this traversal
    • preOrder

      public Object preOrder(NodeVisitor nodeVisitor, 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 nodes
      roots - the root nodes
      Returns:
      the accumulation result of this traversal
    • postOrder

      public Object postOrder(NodeVisitor nodeVisitor, Node root)
      Version of postOrder(NodeVisitor, Collection) with one root.
      Parameters:
      nodeVisitor - the visitor of the nodes
      root - the root node
      Returns:
      the accumulation result of this traversal
    • postOrder

      public Object postOrder(NodeVisitor nodeVisitor, 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 nodes
      roots - the root nodes
      Returns:
      the accumulation result of this traversal
    • oneVisitWithResult

      public static <T> T oneVisitWithResult(Node node, NodeVisitor nodeVisitor)