Package org.parboiled.trees
Class MutableTreeNodeImpl<T extends MutableTreeNode<T>>
- java.lang.Object
-
- org.parboiled.trees.MutableTreeNodeImpl<T>
-
- Type Parameters:
T- the actual implementation type of this MutableTreeNodeImpl
- All Implemented Interfaces:
GraphNode<T>,MutableTreeNode<T>,TreeNode<T>
- Direct Known Subclasses:
MutableBinaryTreeNodeImpl
public class MutableTreeNodeImpl<T extends MutableTreeNode<T>> extends java.lang.Object implements MutableTreeNode<T>
A base implementation of theMutableTreeNode.
-
-
Constructor Summary
Constructors Constructor Description MutableTreeNodeImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddChild(int index, T child)Adds the given child to this nodes children list and setting the childs parent field to this node.java.util.List<T>getChildren()Returns the sub nodes of this node.TgetParent()Returns the parent node or null if this node is the root.TremoveChild(int index)Removes the child with the given index.voidsetChild(int index, T child)Sets the child node at the given index to the given node.
-
-
-
Method Detail
-
getParent
public T getParent()
Description copied from interface:TreeNodeReturns the parent node or null if this node is the root.- Specified by:
getParentin interfaceTreeNode<T extends MutableTreeNode<T>>- Returns:
- the parent node
-
getChildren
public java.util.List<T> getChildren()
Description copied from interface:GraphNodeReturns the sub nodes of this node.- Specified by:
getChildrenin interfaceGraphNode<T extends MutableTreeNode<T>>- Returns:
- the sub nodes
-
addChild
public void addChild(int index, T child)Description copied from interface:MutableTreeNodeAdds the given child to this nodes children list and setting the childs parent field to this node. If the child is currently attached to another node it is first removed.- Specified by:
addChildin interfaceMutableTreeNode<T extends MutableTreeNode<T>>- Parameters:
index- the index under which to insert this child into the children listchild- the child node to add
-
setChild
public void setChild(int index, T child)Description copied from interface:MutableTreeNodeSets the child node at the given index to the given node. The node previously existing at the given child index is first properly removed by setting its parent field to null. If the child is currently attached to another node it is first removed from its old parent.- Specified by:
setChildin interfaceMutableTreeNode<T extends MutableTreeNode<T>>- Parameters:
index- the index under which to set this child into the children listchild- the child node to set
-
removeChild
public T removeChild(int index)
Description copied from interface:MutableTreeNodeRemoves the child with the given index.- Specified by:
removeChildin interfaceMutableTreeNode<T extends MutableTreeNode<T>>- Parameters:
index- the index of the child to remove.- Returns:
- the removed child
-
-