public abstract class ReferenceWalker<T> extends Object
A walker for walking through an object reference structure (e.g. an execution tree).
Any visited element can have any number of following elements. The elements are visited
with a breadth-first approach: The walker maintains a list of next elements to which it adds
a new elements at the end whenever it has visited an element. The walker stops when it encounters
an element that fulfills the given ReferenceWalker.WalkCondition
.
Subclasses define the type of objects and provide the walking behavior.
Modifier and Type | Class and Description |
---|---|
static class |
ReferenceWalker.NullCondition<S> |
static interface |
ReferenceWalker.WalkCondition<S> |
Modifier and Type | Field and Description |
---|---|
protected List<T> |
currentElements |
protected List<TreeVisitor<T>> |
postVisitor |
protected List<TreeVisitor<T>> |
preVisitor |
Constructor and Description |
---|
ReferenceWalker(List<T> initialElements) |
ReferenceWalker(T initialElement) |
Modifier and Type | Method and Description |
---|---|
ReferenceWalker<T> |
addPostVisitor(TreeVisitor<T> collector) |
ReferenceWalker<T> |
addPreVisitor(TreeVisitor<T> collector) |
T |
getCurrentElement() |
protected abstract Collection<T> |
nextElements() |
T |
walkUntil() |
T |
walkUntil(ReferenceWalker.WalkCondition<T> condition) |
T |
walkWhile() |
T |
walkWhile(ReferenceWalker.WalkCondition<T> condition) |
protected List<TreeVisitor<T>> preVisitor
protected List<TreeVisitor<T>> postVisitor
public ReferenceWalker(T initialElement)
protected abstract Collection<T> nextElements()
public ReferenceWalker<T> addPreVisitor(TreeVisitor<T> collector)
public ReferenceWalker<T> addPostVisitor(TreeVisitor<T> collector)
public T walkWhile()
public T walkUntil()
public T walkWhile(ReferenceWalker.WalkCondition<T> condition)
public T walkUntil(ReferenceWalker.WalkCondition<T> condition)
public T getCurrentElement()
Copyright © 2017. All rights reserved.