T - public class TreeBranch<T extends Serializable> extends Object implements Serializable, TreeNode, Iterable<T>
| Modifier and Type | Class and Description |
|---|---|
protected static class |
TreeBranch.PreOrderIterator<X extends Serializable>
inner class that delegates to PreOrderNodeIterator
to fetch content in pre-order.
|
protected static class |
TreeBranch.PreOrderNodeIterator<X extends Serializable>
Inner class to fetch nodes in pre-order.
|
| Modifier | Constructor and Description |
|---|---|
protected |
TreeBranch()
Avoid using this constructor: for beans purposes use
the constructor annotated with ConstructorProperties
|
|
TreeBranch(T content)
to be used initially to build the root (avoid otherwise)
|
|
TreeBranch(TreeBranch<T> parent,
T content)
prefer the use of this constructor when building a tree
(instead of using sequence one-arg constructor + addChild)
|
| Modifier and Type | Method and Description |
|---|---|
void |
addChild(TreeBranch<T> child)
adds a child to the current node.
|
Enumeration |
children() |
String |
deepString()
returns a String that represents the tree
|
protected String |
deepString(int level) |
boolean |
getAllowsChildren()
since the tree is immutable this method is not intended to be called during building operations.
|
TreeNode |
getChildAt(int childIndex) |
int |
getChildCount() |
Iterator<TreeBranch<T>> |
getChildIterator() |
List<TreeBranch<T>> |
getChildren() |
T |
getContent() |
int |
getCurrentIndex() |
int |
getIndex(TreeNode node) |
TreeNode |
getParent() |
List<TreeBranch<T>> |
getPath() |
TreeBranch<T> |
getRealParent()
same as getParent but with proper return type
|
boolean |
isLeaf() |
boolean |
isRootNode() |
Iterator<T> |
iterator() |
Iterator<TreeBranch<T>> |
nodeIterator() |
void |
setContent(T content) |
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitforEach, spliteratorpublic TreeBranch(T content)
content - protected TreeBranch()
@ConstructorProperties(value={"realParent","content"}) public TreeBranch(TreeBranch<T> parent, T content)
parent - may be null if node is intended as a root Node.content - public void addChild(TreeBranch<T> child)
child - public T getContent()
public void setContent(T content)
content - the content to be setpublic int getCurrentIndex()
public Iterator<T> iterator()
iterator in interface Iterable<T extends Serializable>public Iterator<TreeBranch<T>> nodeIterator()
public List<TreeBranch<T>> getChildren()
public Iterator<TreeBranch<T>> getChildIterator()
public List<TreeBranch<T>> getPath()
public TreeNode getChildAt(int childIndex)
getChildAt in interface TreeNodechildIndex - public int getChildCount()
getChildCount in interface TreeNodepublic TreeNode getParent()
public TreeBranch<T> getRealParent()
public int getIndex(TreeNode node)
public boolean getAllowsChildren()
getAllowsChildren in interface TreeNodepublic boolean isLeaf()
public boolean isRootNode()
public Enumeration children()
public String toString()
public String deepString()
protected String deepString(int level)
Copyright © 2022 LSST. All rights reserved.