K
- key used to identify children, e.g. String.public class SimpleTreeNode<K> extends java.lang.Object
TreeUtils
. See
TreeUtilsTest for an application of this class that uses strings as keys.Constructor and Description |
---|
SimpleTreeNode(K key)
Create new node with specified key.
|
Modifier and Type | Method and Description |
---|---|
void |
addChild(SimpleTreeNode<K> child)
Add child.
|
SimpleTreeNode<K> |
getChild(K key)
Returns the child with specified key.
|
UnmodifiableCollection<SimpleTreeNode<K>> |
getChildren()
Returns the children of this node.
|
K |
getKey()
Returns the key of this node.
|
java.lang.String |
toString()
This returns a nicely indented representation of the whole tree below this
node.
|
public SimpleTreeNode(K key)
public SimpleTreeNode<K> getChild(K key)
null
if child
with provided key does not exist.public void addChild(SimpleTreeNode<K> child)
public UnmodifiableCollection<SimpleTreeNode<K>> getChildren()
public java.lang.String toString()
toString
in class java.lang.Object