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 Object
implements MutableTreeNode<T>
A base implementation of the
MutableTreeNode
.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds the given child to this nodes children list and setting the childs parent field to this node.Returns the sub nodes of this node.Returns the parent node or null if this node is the root.removeChild
(int index) Removes the child with the given index.void
Sets the child node at the given index to the given node.
-
Constructor Details
-
MutableTreeNodeImpl
public MutableTreeNodeImpl()
-
-
Method Details
-
getParent
Description copied from interface:TreeNode
Returns the parent node or null if this node is the root.- Specified by:
getParent
in interfaceTreeNode<T extends MutableTreeNode<T>>
- Returns:
- the parent node
-
getChildren
Description copied from interface:GraphNode
Returns the sub nodes of this node.- Specified by:
getChildren
in interfaceGraphNode<T extends MutableTreeNode<T>>
- Returns:
- the sub nodes
-
addChild
Description copied from interface:MutableTreeNode
Adds 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:
addChild
in 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
Description copied from interface:MutableTreeNode
Sets 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:
setChild
in 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
Description copied from interface:MutableTreeNode
Removes the child with the given index.- Specified by:
removeChild
in interfaceMutableTreeNode<T extends MutableTreeNode<T>>
- Parameters:
index
- the index of the child to remove.- Returns:
- the removed child
-