@PublicApi public class QueryTraversal extends java.lang.Object
This is an important distinction to just traversing the Document without any type information: Each field has a clearly
defined type. See QueryVisitorFieldEnvironment
.
Further are the built in Directives skip/include automatically evaluated: if parts of the Document should be ignored they will not be visited. But this is not a full evaluation of a Query: every fragment will be visited/followed regardless of the type condition.
It also doesn't consider field merging, which means for example { user{firstName} user{firstName}}
will result in four
visitField calls.
Modifier and Type | Class and Description |
---|---|
static class |
QueryTraversal.Builder |
Modifier and Type | Method and Description |
---|---|
static QueryTraversal.Builder |
newQueryTraversal() |
<T> T |
reducePostOrder(QueryReducer<T> queryReducer,
T initialValue)
Reduces the fields of a Document (or parts of it) to a single value.
|
<T> T |
reducePreOrder(QueryReducer<T> queryReducer,
T initialValue)
Reduces the fields of a Document (or parts of it) to a single value.
|
Node |
transform(QueryVisitor queryVisitor)
Visits the Document in pre-order and allows to transform it using
TreeTransformerUtil
methods. |
java.lang.Object |
visitDepthFirst(QueryVisitor queryVisitor) |
void |
visitPostOrder(QueryVisitor visitor)
Visits the Document (or parts of it) in post-order.
|
void |
visitPreOrder(QueryVisitor visitor)
Visits the Document (or parts of it) in pre-order.
|
public java.lang.Object visitDepthFirst(QueryVisitor queryVisitor)
public void visitPostOrder(QueryVisitor visitor)
visitor
- the query visitor that will be called backpublic void visitPreOrder(QueryVisitor visitor)
visitor
- the query visitor that will be called backpublic Node transform(QueryVisitor queryVisitor)
TreeTransformerUtil
methods. This method requires single root element. Please note that fragments are not visited and need to be
processed explicitly by supplying them as root.queryVisitor
- the query visitor that will be called back.java.lang.IllegalArgumentException
- if there are multiple root nodes.public <T> T reducePostOrder(QueryReducer<T> queryReducer, T initialValue)
T
- the type of reduced valuequeryReducer
- the query reducerinitialValue
- the initial value to pass to the reducerpublic <T> T reducePreOrder(QueryReducer<T> queryReducer, T initialValue)
T
- the type of reduced valuequeryReducer
- the query reducerinitialValue
- the initial value to pass to the reducerpublic static QueryTraversal.Builder newQueryTraversal()