Class Node<T>

java.lang.Object
io.jmix.core.common.datastruct.Node<T>
All Implemented Interfaces:
Serializable

public class Node<T> extends Object implements Serializable
See Also:
  • Field Details

    • data

      public T data
    • parent

      public Node<T> parent
    • children

      public List<Node<T>> children
  • Constructor Details

    • Node

      public Node()
    • Node

      public Node(T data)
      Convenience constructor to create a Node<T> with an instance of T.
      Parameters:
      data - an instance of T.
  • Method Details

    • getChildren

      public List<Node<T>> getChildren()
      Return the children of Node<T>. The Tree<T> is represented by a single root Node<T> whose children are represented by a List<Node<T>>. Each of these Node<T> elements in the List can have children. The getChildren() method will return the children of a Node<T>.
      Returns:
      the children of Node<T>
    • getParent

      public Node<T> getParent()
    • setChildren

      public void setChildren(List<Node<T>> children)
      Sets the children of a Node<T> object. See docs for getChildren() for more information.
      Parameters:
      children - the List<Node<T>> to set.
    • getNumberOfChildren

      public int getNumberOfChildren()
      Returns the number of immediate children of this Node<T>.
      Returns:
      the number of immediate children.
    • addChild

      public void addChild(Node<T> child)
      Adds a child to the list of children for this Node<T>. The addition of the first child will create a new List<Node<T>>.
      Parameters:
      child - a Node<T> object to set.
    • insertChildAt

      public void insertChildAt(int index, Node<T> child) throws IndexOutOfBoundsException
      Inserts a Node<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 - the Node<T> object to insert.
      Throws:
      IndexOutOfBoundsException - if thrown.
    • removeChildAt

      public void removeChildAt(int index) throws IndexOutOfBoundsException
      Remove the Node<T> element at index index of the List<Node<T>>.
      Parameters:
      index - the index of the element to delete.
      Throws:
      IndexOutOfBoundsException - if thrown.
    • getData

      public T getData()
    • setData

      public void setData(T data)
    • toString

      public String toString()
      Overrides:
      toString in class Object