CHILD - is the generic type of the children.PARENT - is the generic type of the parent.public abstract class AbstractGenericTreeNode<CHILD extends Node<PARENT>,PARENT extends GenericTreeNode<CHILD,PARENT>> extends Object implements GenericTreeNode<CHILD,PARENT>
GenericTreeNode interface.| Modifier and Type | Field and Description |
|---|---|
private List<CHILD> |
children |
private List<CHILD> |
mutableChildList |
private PARENT |
parent |
| Constructor and Description |
|---|
AbstractGenericTreeNode()
The constructor.
|
AbstractGenericTreeNode(ListFactory listFactory)
The constructor.
|
AbstractGenericTreeNode(PARENT parent)
The constructor.
|
AbstractGenericTreeNode(PARENT parent,
ListFactory listFactory)
The constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
addChild(CHILD child)
|
protected void |
addChild(CHILD child,
int index)
|
List<CHILD> |
getChildren()
This method gets the
List containing all children of this GenericTreeNode. |
protected List<CHILD> |
getMutableChildList() |
PARENT |
getParent()
This method gets the parent of this
GenericTreeNode. |
boolean |
isAncestor(PARENT node)
This method determines if this
GenericTreeNode is an ancestor of the given node. |
boolean |
isDescendant(CHILD node)
This method determines if this
GenericTreeNode is a descendant of the given node. |
protected boolean |
removeChild(CHILD child)
|
protected CHILD |
removeChild(int index)
|
protected void |
setParent(PARENT parent)
This method sets the
parent of this GenericTreeNode. |
private PARENT extends GenericTreeNode<CHILD,PARENT> parent
public AbstractGenericTreeNode()
public AbstractGenericTreeNode(PARENT parent)
parent - is the parent node.public AbstractGenericTreeNode(ListFactory listFactory)
listFactory - the factory used to create the internal List.public AbstractGenericTreeNode(PARENT parent, ListFactory listFactory)
public PARENT getParent()
GenericTreeNodeGenericTreeNode.getParent in interface GenericTreeNode<CHILD extends Node<PARENT>,PARENT extends GenericTreeNode<CHILD,PARENT>>getParent in interface Node<PARENT extends GenericTreeNode<CHILD,PARENT>>GenericTreeNode or null if this is the root- GenericTreeNode.protected void setParent(PARENT parent)
parent of this GenericTreeNode.parent - is the parent to set. It may be null. However you should typically only
call this method once with a non-null argument. It is still legal to re-arrange the tree-structure on
existing GenericTreeNodes.public List<CHILD> getChildren()
GenericTreeNodeList containing all children of this GenericTreeNode. The List may be
empty - in such case we call this GenericTreeNode a leaf . Each item of the
returned List is called a child or child-node. It should return this
GenericTreeNode as parent.getChildren in interface GenericTreeNode<CHILD extends Node<PARENT>,PARENT extends GenericTreeNode<CHILD,PARENT>>List containing all children of this GenericTreeNode.protected void addChild(CHILD child)
child - is the child to add. It's parent has to be identical to
this GenericTreeNode.protected void addChild(CHILD child, int index)
child - is the child to add. It's parent has to be identical to
this GenericTreeNode.index - is the index where to insert the new child.protected boolean removeChild(CHILD child)
child - is the child to remove.true if the given child was contained in this GenericTreeNodes
children and has been removed successfully, false otherwise.protected CHILD removeChild(int index)
public boolean isAncestor(PARENT node)
GenericTreeNodeGenericTreeNode is an ancestor of the given node. In other words
this method checks if this GenericTreeNode is the direct or indirect parent of the
given node.isAncestor in interface GenericTreeNode<CHILD extends Node<PARENT>,PARENT extends GenericTreeNode<CHILD,PARENT>>node - is the GenericTreeNode to check (the potential descendant ).true if this GenericTreeNode is an ancestor of the given node.public boolean isDescendant(CHILD node)
GenericTreeNodeGenericTreeNode is a descendant of the given node. In other words
this method checks if this GenericTreeNode is the direct or indirect child of the
given node.isDescendant in interface GenericTreeNode<CHILD extends Node<PARENT>,PARENT extends GenericTreeNode<CHILD,PARENT>>node - is the GenericTreeNode to check (the potential ancestor).true if this GenericTreeNode is an descendant of the given node .Copyright © 2001–2016 mmm-Team. All rights reserved.