S - - Self typepublic class TreeNode<S extends TreeNode<S>>
extends java.lang.Object
implements java.lang.Iterable<S>
| Modifier and Type | Field and Description |
|---|---|
java.util.Set<S> |
children
The children of the node.
|
protected java.util.Optional<S> |
parent
The parent of the node.
|
| Constructor and Description |
|---|
TreeNode() |
| Modifier and Type | Method and Description |
|---|---|
S |
addChild(S node)
Adds a childnode to the node
|
java.util.Set<S> |
children()
Get the direct childnodes
|
java.util.Set<S> |
descendants()
Gets all child nodes recursively
|
boolean |
exists(S targetChild)
Checks recursively to see if any of the children can match the given child.
|
java.util.Optional<S> |
getParent()
The parrent of this node
|
java.util.List<S> |
hierarchy() |
java.util.Iterator<S> |
iterator() |
S |
removeChild(S child)
Remove a childnode
|
void |
setParent(java.util.Optional<S> parent)
Set's the parrent of this node
|
java.util.Spliterator<S> |
spliterator() |
java.util.stream.Stream<S> |
stream() |
public java.util.Optional<S> getParent()
public void setParent(java.util.Optional<S> parent)
parent - The new parrent of this nodepublic S addChild(S node)
node - The childnode to addpublic S removeChild(S child)
child - The childnode to removepublic java.util.Set<S> children()
public java.util.Set<S> descendants()
public boolean exists(S targetChild)
targetChild - - The target match to find.public java.util.List<S> hierarchy()
public java.util.stream.Stream<S> stream()
public java.util.Iterator<S> iterator()