T
- The type of the wrapped data of the tree node.public class ListTreeModel<T> extends Object implements TreeModel<T>
Constructor and Description |
---|
ListTreeModel() |
Modifier and Type | Method and Description |
---|---|
TreeModel<T> |
addChild(T data)
Creates and adds a child tree node with the given wrapped data to the current tree node.
|
TreeModel<T> |
addChildNode(TreeModel<T> child)
Adds the given child tree node to the current tree node.
|
boolean |
equals(Object object) |
int |
getChildCount()
Returns the count of the children of the current tree node.
|
List<TreeModel<T>> |
getChildren()
Returns an unmodifiable list of all child tree nodes of the current tree node.
|
T |
getData()
Returns the wrapped data of the current tree node.
|
String |
getIndex()
Returns the zero-based unique index of the current tree node.
|
int |
getLevel()
Returns the level of the current tree node.
|
TreeModel<T> |
getParent()
Returns the parent tree node of the current tree node.
|
int |
hashCode() |
boolean |
isFirst()
Returns whether the current tree node is the first child of its parent, if any.
|
boolean |
isLast()
Returns whether the current tree node is the last child of its parent, if any.
|
boolean |
isLeaf()
Returns whether the current tree node is a leaf node.
|
boolean |
isRoot()
Returns whether the current tree node is the root node.
|
Iterator<TreeModel<T>> |
iterator()
Returns an unmodifiable iterator over the children of the current tree node.
|
TreeModel<T> |
remove()
Removes the current tree node from its parent, if any.
|
void |
setData(T data)
Sets the wrapped data of the current tree node.
|
String |
toString() |
public void setData(T data)
TreeModel
public TreeModel<T> addChild(T data)
TreeModel
public TreeModel<T> addChildNode(TreeModel<T> child)
TreeModel
addChildNode
in interface TreeModel<T>
child
- The child tree node to be added.public TreeModel<T> remove()
TreeModel
public T getData()
TreeModel
public TreeModel<T> getParent()
TreeModel
public int getChildCount()
TreeModel
getChildCount
in interface TreeModel<T>
public List<TreeModel<T>> getChildren()
TreeModel
TreeModel.addChild(Object)
method on the
tree node parent. Removing children should be done by the TreeModel.remove()
method on the tree node itself.getChildren
in interface TreeModel<T>
public Iterator<TreeModel<T>> iterator()
TreeModel
public int getLevel()
TreeModel
public String getIndex()
TreeModel
null
. The first child has
index 0. The second child of first child has index 0_1. The first child of second child of
third child has index 2_1_0.public boolean isRoot()
TreeModel
public boolean isLeaf()
TreeModel
public boolean isFirst()
TreeModel
public boolean isLast()
TreeModel