public interface Traverser<T> extends Serializable, Comparable<Traverser<T>>, Cloneable
Traverser
represents the current state of an object flowing through a Traversal
.
A traverser maintains a reference to the current object, a traverser-local "sack", a traversal-global sideEffect,
a bulk count, and a path history.
Different types of traversers can exist depending on the semantics of the traversal and the desire for
space/time optimizations of the developer.Modifier and Type | Interface and Description |
---|---|
static interface |
Traverser.Admin<T>
The methods in System.Traverser are useful to underlying Step and Traversal implementations.
|
Modifier and Type | Method and Description |
---|---|
default Traverser.Admin<T> |
asAdmin()
Typecast the traverser to a "system traverser" so
Traverser.Admin methods can be accessed. |
long |
bulk()
A traverser may represent a grouping of traversers to allow for more efficient data propagation.
|
Traverser<T> |
clone()
Traverser cloning is important when splitting a traverser at a bifurcation point in a traversal.
|
default int |
compareTo(Traverser<T> other)
If the underlying object of the traverser is comparable, compare it with the other traverser.
|
T |
get()
Get the object that the traverser is current at.
|
int |
loops()
Return the number of times the traverser has gone through a looping section of a traversal.
|
Path |
path()
Get the current path of the traverser.
|
default <A> A |
path(Pop pop,
String stepLabel) |
default <A> A |
path(String stepLabel)
Get the object associated with the specified step-label in the traverser's path history.
|
<S> S |
sack()
Get the sack local sack object of this traverser.
|
<S> void |
sack(S object)
Set the traversers sack object to the provided value ("sack the value").
|
default <A> A |
sideEffects(String sideEffectKey)
Get a particular value from the sideEffects of the traverser.
|
default void |
sideEffects(String sideEffectKey,
Object sideEffectValue)
Set a particular value in the sideEffects of the traverser.
|
T get()
<S> S sack()
S
- the type of the sack object<S> void sack(S object)
S
- the type of the objectobject
- the new value of the traverser's sackPath path()
default <A> A path(String stepLabel)
A
- the type of the objectstepLabel
- the step-label in the path to accessint loops()
long bulk()
default <A> A sideEffects(String sideEffectKey)
A
- the type of the returned objectsideEffectKey
- the key of the value to get from the sideEffectsdefault void sideEffects(String sideEffectKey, Object sideEffectValue)
sideEffectKey
- the key of the value to set int the sideEffectssideEffectValue
- the value to set for the sideEffect keydefault int compareTo(Traverser<T> other) throws ClassCastException
compareTo
in interface Comparable<Traverser<T>>
other
- the other traverser that presumably has a comparable internal objectClassCastException
- if the object of the traverser is not comparabledefault Traverser.Admin<T> asAdmin()
Traverser.Admin
methods can be accessed.
This is used as a helper method to avoid the awkwardness of ((Traverser.Administrative)traverser)
.
The default implementation simply returns "this" type casted to Traverser.Admin
.Copyright © 2013–2017 Apache Software Foundation. All rights reserved.