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() |
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()
TraverserContext
TraverserContext.changeNode(Object)
is called.
Throws Exception if the node is deleted.thisNode
in interface TraverserContext<T>
public T originalThisNode()
TraverserContext
originalThisNode
in interface TraverserContext<T>
public void changeNode(T newNode)
TraverserContext
changeNode
in interface TraverserContext<T>
newNode
- the new Nodepublic void deleteNode()
TraverserContext
deleteNode
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()
TraverserContext
TraverserContext.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()
TraverserContext
getParentNodes
in interface TraverserContext<T>
public java.util.List<Breadcrumb<T>> getBreadcrumbs()
TraverserContext
Breadcrumb
getBreadcrumbs
in interface TraverserContext<T>
public T getParentNode()
TraverserContext
getParentNode
in interface TraverserContext<T>
public java.util.Set<T> visitedNodes()
TraverserContext
TraverserVisitor.enter(graphql.util.TraverserContext)
methodvisitedNodes
in interface TraverserContext<T>
public boolean isVisited()
TraverserContext
isVisited
in interface TraverserContext<T>
true
if a node had been already visitedpublic <S> S getVar(java.lang.Class<? super S> key)
TraverserContext
getVar
in interface TraverserContext<T>
S
- type of the variablekey
- key to lookup the variable valuenull
public <S> TraverserContext<T> setVar(java.lang.Class<? super S> key, S value)
TraverserContext
setVar
in interface TraverserContext<T>
S
- type of a variablekey
- key to create bindings for the variablevalue
- value of variablepublic void setAccumulate(java.lang.Object accumulate)
TraverserContext
TraverserContext.getNewAccumulate()
setAccumulate
in interface TraverserContext<T>
accumulate
- to setpublic <U> U getNewAccumulate()
TraverserContext
TraverserContext.setAccumulate(Object)
or TraverserContext.getCurrentAccumulate()
if TraverserContext.setAccumulate(Object)
not invoked.getNewAccumulate
in interface TraverserContext<T>
U
- and mepublic <U> U getCurrentAccumulate()
TraverserContext
getCurrentAccumulate
in interface TraverserContext<T>
U
- and mepublic java.lang.Object getSharedContextData()
TraverserContext
getSharedContextData
in interface TraverserContext<T>
public NodeLocation getLocation()
TraverserContext
getLocation
in interface TraverserContext<T>
public boolean isRootContext()
TraverserContext
isRootContext
in interface TraverserContext<T>
public <S> S getVarFromParents(java.lang.Class<? super S> key)
TraverserContext
getVarFromParents
in interface TraverserContext<T>
S
- type of the variablekey
- key to lookup the variable valuenull
public java.util.Map<java.lang.String,java.util.List<TraverserContext<T>>> getChildrenContexts()
TraverserContext
getChildrenContexts
in interface TraverserContext<T>
public TraverserContext.Phase getPhase()
getPhase
in interface TraverserContext<T>
public boolean isParallel()
isParallel
in interface TraverserContext<T>