Class QueryTreeWalker


  • public class QueryTreeWalker
    extends DslBase
    Walks a tree of Query objects, performing a user-specified callback at each "node" in the tree.
    • Constructor Detail

      • QueryTreeWalker

        public QueryTreeWalker()
    • Method Detail

      • depthFirstWalk

        public void depthFirstWalk​(QueryDefinition queryDefinition,
                                   java.util.function.Function<QueryTreeWalker.QueryWalkContext,​QueryTreeAction> perNodeAction)
        Performs a depth-first walk of the main query in the specified QueryDefinition Our walk processes the whole tree by default. However, if the provided callback replaces the Query currently being processed, the walk skips over any children in that subtree to limit the risk of accidental infinite-recursion or double-visiting.
        Parameters:
        queryDefinition - the DSL definition containing the query-tree to walk
        perNodeAction - a Function to process each node as it's visited. If any modifications are being made to the node (or its children), the Function can return a new query object which should replace the current query's position within the tree. Function's that don't modify the tree in any way can return the Query object attached to the current QueryWalkContext