public abstract class AbstractTreeNode extends Object implements TreeNode
| Constructor and Description |
|---|
AbstractTreeNode()
Create a new instance of a
AbstractTreeNode that serves as root for a tree. |
| Modifier and Type | Method and Description |
|---|---|
void |
addChild(TreeNode child)
Add a child node below this node.
|
TreeNode |
getChild(int index)
Get child node by position in the list of siblings.
|
List<TreeNode> |
getChildren()
Get all child nodes of this node
|
TreeNode |
getParent()
Get the parent of this node
|
TreeNode |
getRoot()
Get the root of the tree
|
boolean |
isChild()
Check whether this node is a child node
|
boolean |
isFirstSibling()
Check whether a child is the first in the list of siblings
|
boolean |
isRoot()
Check whether this node is the root of the tree.
|
boolean |
isSibling(TreeNode node)
Check whether this node is a sibling of the second node.
|
void |
setParent(TreeNode parent)
Link to a parent node
|
public AbstractTreeNode()
AbstractTreeNode that serves as root for a tree.public void setParent(TreeNode parent)
setParent in interface TreeNodeparent - the parent to which this node will be linked as a childIllegalArgumentException - if parent is null or parent and child are identicalpublic TreeNode getRoot()
TreeNodepublic TreeNode getParent()
TreeNodepublic void addChild(TreeNode child)
TreeNodeImportant: this also automatically creates a link in the opposite direction. All implementations must adhere to this rule.
public List<TreeNode> getChildren()
TreeNodegetChildren in interface TreeNodepublic TreeNode getChild(int index)
TreeNodepublic boolean isRoot()
TreeNodepublic boolean isChild()
TreeNodepublic boolean isFirstSibling()
TreeNodeisFirstSibling in interface TreeNodetrue if the child is the first in the list of siblingsCopyright © 2018–2020. All rights reserved.