Modifier and Type | Class and Description |
---|---|
static class |
QueryTreeWalker.QueryWalkContext |
Constructor and Description |
---|
QueryTreeWalker() |
Modifier and Type | Method and Description |
---|---|
static Stream<QueryTreeWalker.QueryWalkContext> |
contextStream(QueryDefinition qd)
Creates a stream populated by a depth-first walk of the query-tree
Callers should beware using the
QueryTreeWalker.QueryWalkContext to modify the links between queries as tree branches may
be orphaned or dropped from iteration as a result. |
void |
depthFirstWalk(QueryDefinition queryDefinition,
Function<QueryTreeWalker.QueryWalkContext,Query> perNodeAction)
Performs a depth-first walk of the main query in the specified
QueryDefinition
Our walk processes the whole tree by default. |
public void depthFirstWalk(QueryDefinition queryDefinition, Function<QueryTreeWalker.QueryWalkContext,Query> perNodeAction)
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.queryDefinition
- the DSL definition containing the query-tree to walkperNodeAction
- 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 QueryWalkContextpublic static Stream<QueryTreeWalker.QueryWalkContext> contextStream(QueryDefinition qd)
QueryTreeWalker.QueryWalkContext
to modify the links between queries as tree branches may
be orphaned or dropped from iteration as a result.