public class DefaultTraverserContext<T> extends java.lang.Object implements TraverserContext<T>
TraverserContext.Phase| Constructor and Description |
|---|
DefaultTraverserContext(T curNode,
TraverserContext<T> parent,
java.util.Set<T> visited,
java.util.Map<java.lang.Class<?>,java.lang.Object> vars,
java.lang.Object sharedContextData,
NodeLocation location,
boolean isRootContext,
boolean parallel) |
| Modifier and Type | Method and Description |
|---|---|
void |
changeNode(T newNode)
Change the current node to the provided node.
|
void |
deleteNode()
Deletes the current node.
|
static <T> DefaultTraverserContext<T> |
dummy() |
java.util.List<Breadcrumb<T>> |
getBreadcrumbs()
The exact location of this node inside the tree as a list of
Breadcrumb |
java.util.Map<java.lang.String,java.util.List<TraverserContext<T>>> |
getChildrenContexts()
In case of leave returns the children contexts, which have already been visited.
|
<U> U |
getCurrentAccumulate()
The current accumulate value used as "input" for the current step.
|
NodeLocation |
getLocation()
The location of the current node regarding to the parent node.
|
<U> U |
getNewAccumulate()
The new accumulate value, previously set by
TraverserContext.setAccumulate(Object)
or TraverserContext.getCurrentAccumulate() if TraverserContext.setAccumulate(Object) not invoked. |
TraverserContext<T> |
getParentContext()
Returns parent context.
|
T |
getParentNode()
The parent node.
|
java.util.List<T> |
getParentNodes()
The list of parent nodes starting from the current parent.
|
TraverserContext.Phase |
getPhase() |
java.lang.Object |
getSharedContextData()
Used to share something across all TraverserContext.
|
<S> S |
getVar(java.lang.Class<? super S> key)
Obtains a context local variable
|
<S> S |
getVarFromParents(java.lang.Class<? super S> key)
Searches for a context variable starting from the parent
up the hierarchy of contexts until the first variable is found.
|
boolean |
isChanged() |
boolean |
isDeleted() |
boolean |
isParallel()
If the traversing happens in parallel (multi threaded) or not.
|
boolean |
isRootContext()
Returns true for the root context, which doesn't have a node or a position.
|
boolean |
isVisited()
Informs that the current node has been already "visited"
|
T |
originalThisNode()
Returns the original, unchanged, not deleted Node.
|
void |
setAccumulate(java.lang.Object accumulate)
Sets the new accumulate value.
|
<S> TraverserContext<T> |
setVar(java.lang.Class<? super S> key,
S value)
Stores a variable in the context
|
static <T> DefaultTraverserContext<T> |
simple(T node) |
T |
thisNode()
Returns current node being visited.
|
java.util.Set<T> |
visitedNodes()
Obtains all visited nodes and values received by the
TraverserVisitor.enter(graphql.util.TraverserContext)
method |
public DefaultTraverserContext(T curNode, TraverserContext<T> parent, java.util.Set<T> visited, java.util.Map<java.lang.Class<?>,java.lang.Object> vars, java.lang.Object sharedContextData, NodeLocation location, boolean isRootContext, boolean parallel)
public static <T> DefaultTraverserContext<T> dummy()
public static <T> DefaultTraverserContext<T> simple(T node)
public T thisNode()
TraverserContextTraverserContext.changeNode(Object) is called.
Throws Exception if the node is deleted.thisNode in interface TraverserContext<T>public T originalThisNode()
TraverserContextoriginalThisNode in interface TraverserContext<T>public void changeNode(T newNode)
TraverserContextchangeNode in interface TraverserContext<T>newNode - the new Nodepublic void deleteNode()
TraverserContextdeleteNode in interface TraverserContext<T>public boolean isDeleted()
isDeleted in interface TraverserContext<T>TraverserContext.deleteNode()public boolean isChanged()
isChanged in interface TraverserContext<T>TraverserContext.changeNode(Object)public TraverserContext<T> getParentContext()
TraverserContextTraverserContext.getParentContext() links one could obtain
the current path as well as the variables TraverserContext.getVar(java.lang.Class)
stored in every parent context.getParentContext in interface TraverserContext<T>public java.util.List<T> getParentNodes()
TraverserContextgetParentNodes in interface TraverserContext<T>public java.util.List<Breadcrumb<T>> getBreadcrumbs()
TraverserContextBreadcrumbgetBreadcrumbs in interface TraverserContext<T>public T getParentNode()
TraverserContextgetParentNode in interface TraverserContext<T>public java.util.Set<T> visitedNodes()
TraverserContextTraverserVisitor.enter(graphql.util.TraverserContext)
methodvisitedNodes in interface TraverserContext<T>public boolean isVisited()
TraverserContextisVisited in interface TraverserContext<T>true if a node had been already visitedpublic <S> S getVar(java.lang.Class<? super S> key)
TraverserContextgetVar in interface TraverserContext<T>S - type of the variablekey - key to lookup the variable valuenullpublic <S> TraverserContext<T> setVar(java.lang.Class<? super S> key, S value)
TraverserContextsetVar in interface TraverserContext<T>S - type of a varablekey - key to create bindings for the variablevalue - value of variablepublic void setAccumulate(java.lang.Object accumulate)
TraverserContextTraverserContext.getNewAccumulate()setAccumulate in interface TraverserContext<T>accumulate - to setpublic <U> U getNewAccumulate()
TraverserContextTraverserContext.setAccumulate(Object)
or TraverserContext.getCurrentAccumulate() if TraverserContext.setAccumulate(Object) not invoked.getNewAccumulate in interface TraverserContext<T>U - and mepublic <U> U getCurrentAccumulate()
TraverserContextgetCurrentAccumulate in interface TraverserContext<T>U - and mepublic java.lang.Object getSharedContextData()
TraverserContextgetSharedContextData in interface TraverserContext<T>public NodeLocation getLocation()
TraverserContextgetLocation in interface TraverserContext<T>public boolean isRootContext()
TraverserContextisRootContext in interface TraverserContext<T>public <S> S getVarFromParents(java.lang.Class<? super S> key)
TraverserContextgetVarFromParents in interface TraverserContext<T>S - type of the variablekey - key to lookup the variable valuenullpublic java.util.Map<java.lang.String,java.util.List<TraverserContext<T>>> getChildrenContexts()
TraverserContextgetChildrenContexts in interface TraverserContext<T>public TraverserContext.Phase getPhase()
getPhase in interface TraverserContext<T>public boolean isParallel()
TraverserContextisParallel in interface TraverserContext<T>