Package io.jmix.core.common.datastruct
Class Node<T>
java.lang.Object
io.jmix.core.common.datastruct.Node<T>
- All Implemented Interfaces:
Serializable
- See Also:
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a child to the list of children for thisNode<T>
.Return the children ofNode<T>
.getData()
int
Returns the number of immediate children of thisNode<T>
.void
insertChildAt
(int index, Node<T> child) Inserts aNode<T>
at the specified position in the child list.void
removeChildAt
(int index) Remove theNode<T>
element at index index of theList<Node<T>>
.void
setChildren
(List<Node<T>> children) Sets the children of aNode<T>
object.void
toString()
-
Field Details
-
data
-
parent
-
children
-
-
Constructor Details
-
Node
public Node() -
Node
Convenience constructor to create aNode<T>
with an instance of T.- Parameters:
data
- an instance of T.
-
-
Method Details
-
getChildren
Return the children ofNode<T>
. TheTree<T>
is represented by a single rootNode<T>
whose children are represented by aList<Node<T>>
. Each of theseNode<T>
elements in the List can have children. The getChildren() method will return the children of aNode<T>
.- Returns:
- the children of
Node<T>
-
getParent
-
setChildren
Sets the children of aNode<T>
object. See docs for getChildren() for more information.- Parameters:
children
- theList<Node<T>>
to set.
-
getNumberOfChildren
public int getNumberOfChildren()Returns the number of immediate children of thisNode<T>
.- Returns:
- the number of immediate children.
-
addChild
Adds a child to the list of children for thisNode<T>
. The addition of the first child will create a newList<Node<T>>
.- Parameters:
child
- aNode<T>
object to set.
-
insertChildAt
Inserts aNode<T>
at the specified position in the child list. Will throw an ArrayIndexOutOfBoundsException if the index does not exist.- Parameters:
index
- the position to insert at.child
- theNode<T>
object to insert.- Throws:
IndexOutOfBoundsException
- if thrown.
-
removeChildAt
Remove theNode<T>
element at index index of theList<Node<T>>
.- Parameters:
index
- the index of the element to delete.- Throws:
IndexOutOfBoundsException
- if thrown.
-
getData
-
setData
-
toString
-