public interface Tree<N> extends Iterable<N>
The VirtualTree is thread safe, in that the VirtualTree itself is not allowed to keep state information other than what is needed to handle the root element.
The Domain structure must be structured in the following way:
All Object parameters and return values defined in this interface are all
domain objects that will need to be typecast back to the domain object when
It is assumed that all Domain objects implement hashCode and equals as specified by
Object
.
The domain objects will assume a natural order that can be used. The natural order starts with the root, and processes each child recursively. The parent object is the first object, followed by the parent's first child, followed by that child's first child, and so on.
Modifier and Type | Method and Description |
---|---|
void |
forEach(Visitor<N> v)
Allow a visitor to visit each node in the hierarchy.
|
View<N> |
getAncestorView(N o)
Return a
View that includes the specified domain object, and its parent, and that parent's parent, and so on up to the root object. |
int |
getChildCount(N o)
Returns the number of children that the specified domain object has.
|
N |
getChildOf(N o,
int index)
Returns the specified child of the specified domain object.
|
N |
getNextOf(N o) |
N |
getParentOf(N o)
Returns the Parent domain object of the specified domain object.
|
N |
getPreviousOf(N o) |
View<N> |
getRecursiveView()
Returns a
View object that includes the whole tree. |
View<N> |
getRecursiveView(boolean includeRoot)
Return a
View object that includes the whole tree, optionally excluding the root element |
View<N> |
getRecursiveView(int depth)
Return a
View that includes the whole tree, clipped at a specific depth. |
View<N> |
getRecursiveView(int depth,
boolean includeRoot)
Return a
View that includes the whole tree, clipped at a specific depth, optionally
excluding the root object. |
View<N> |
getRecursiveView(N o)
Return a
View that includes the specified domain object,
and all of that objects children. |
View<N> |
getRecursiveView(N o,
boolean includeRoot)
Return a
View that optionally includes the specified domain object,
and all of that objects children. |
View<N> |
getRecursiveView(N o,
int depth)
Return a
View that includes the specified domain object,
and all of that objects children, down to a specific level. |
View<N> |
getRecursiveView(N o,
int depth,
boolean includeRoot)
Return a
View that optionally includes the specified domain object,
and all of that objects children, down to a specific level. |
N |
getRoot()
Returns the root of this tree.
|
View<N> |
getView(N o)
Return a
View that includes the specified object, and no other objects. |
boolean |
isRoot(N o)
Returns true if the specified object is the root node.
|
Relationships<N> |
relationships(N pBase,
N pCurrent)
Return a Relationships object that calculates the relationships between the base object and the current object.
|
Walker<N> |
walker(View<N> view)
Return an iterator ("walker") that will go through the specified view
in natural order,
|
forEach, iterator, spliterator
N getRoot()
boolean isRoot(N o)
N getChildOf(N o, int index)
o
- The domain object whose parent hasindex
- The number of the child. The index is zero-based.int getChildCount(N o)
void forEach(Visitor<N> v)
Walker<N> walker(View<N> view)
View<N> getRecursiveView(N o)
View
that includes the specified domain object,
and all of that objects children. In effect, it gives a domain object's
sub-tree.View<N> getRecursiveView(int depth)
View
that includes the whole tree, clipped at a specific depth.depth
- a number typically greater than one. 1 means the domain object itself, 2 means the domain object and its direct children, 3 means one additional level.View<N> getRecursiveView(N o, int depth)
View
that includes the specified domain object,
and all of that objects children, down to a specific level.View<N> getRecursiveView(boolean includeRoot)
View
object that includes the whole tree, optionally excluding the root elementView<N> getRecursiveView(N o, boolean includeRoot)
View
that optionally includes the specified domain object,
and all of that objects children. In effect, it gives a domain object's
sub-tree.View<N> getRecursiveView(int depth, boolean includeRoot)
View
that includes the whole tree, clipped at a specific depth, optionally
excluding the root object.depth
- a number typically greater than one. 1 means the domain object itself, 2 means the domain object and its direct children, 3 means one additional level.View<N> getRecursiveView(N o, int depth, boolean includeRoot)
View
that optionally includes the specified domain object,
and all of that objects children, down to a specific level.View<N> getAncestorView(N o)
View
that includes the specified domain object, and its parent, and that parent's parent, and so on up to the root object. The returned view represents a view of all of the ancestors of the specified domain object.o
- The domain object whose ancestors are to be returnedView<N> getView(N o)
View
that includes the specified object, and no other objects.Relationships<N> relationships(N pBase, N pCurrent)
© 1998- 2021 Escenic AS