Interface ITreeNode<T>

  • Type Parameters:
    T - the generic type
    All Superinterfaces:
    java.io.Serializable
    All Known Implementing Classes:
    TreeNode

    public interface ITreeNode<T>
    extends java.io.Serializable
    The Interface ITreeNode.
    • Method Detail

      • addChild

        default void addChild​(ITreeNode<T> child)
        Adds the child.
        Parameters:
        child - the child
      • addChildAt

        default void addChildAt​(int index,
                                ITreeNode<T> child)
                         throws java.lang.IndexOutOfBoundsException
        Adds the child.
        Parameters:
        index - the index
        child - the child
        Throws:
        java.lang.IndexOutOfBoundsException - the index out of bounds exception
      • getAllSiblings

        default java.util.List<ITreeNode<T>> getAllSiblings()
        Returns all siblings of this node in the parent's children list. Returns null if this node is the root.
        Returns:
        Returns all siblings of this node or null if this node is the root.
      • getChildCount

        default int getChildCount()
        Gets the child count.
        Returns:
        the child count
      • getChildren

        java.util.List<ITreeNode<T>> getChildren()
        Gets the children.
        Returns:
        the children
      • getDepth

        default int getDepth()
        Returns the depth of the tree beginning at this node Returns 0 if this node has no children.
        Returns:
        the depth of the tree beginning at this node.
      • getDisplayValue

        java.lang.String getDisplayValue()
        Gets the optional display value.
        Returns:
        the display value
      • getLevel

        default int getLevel()
        Returns the distance from the root to this node. Returns 0 if this node is the root.
        Returns:
        the level from this node.
      • getNextSibling

        default ITreeNode<T> getNextSibling()
        Returns the next sibling of this node in the parent's children list. Returns null if this node is the root or is the parent's last child.
        Returns:
        the next sibling of this node or null if this node is the root or is the parent's last child.
      • getParent

        ITreeNode<T> getParent()
        Gets the parent.
        Returns:
        the parent
      • getPreviousSibling

        default ITreeNode<T> getPreviousSibling()
        Returns the previous sibling of this node in the parent's children list. Returns null if this node is the root or is the parent's first child.
        Returns:
        the next sibling of this node or null if this node is the root or is the parent's last child.
      • getValue

        T getValue()
        Gets the value.
        Returns:
        the value
      • hasChildren

        default boolean hasChildren()
        Checks for children.
        Returns:
        true, if successful
      • hasParent

        default boolean hasParent()
        Checks for parent
        Returns:
        true, if successful
      • isLeaf

        default boolean isLeaf()
        Checks if is leaf.
        Returns:
        true, if is leaf
      • isNode

        default boolean isNode()
        Checks if is node.
        Returns:
        true, if is node
      • removeChild

        default void removeChild​(ITreeNode<T> child)
        Removes the child.
        Parameters:
        child - the child
      • removeChildAt

        default void removeChildAt​(int index)
                            throws java.lang.IndexOutOfBoundsException
        Removes the child.
        Parameters:
        index - the index
        Throws:
        java.lang.IndexOutOfBoundsException - the index out of bounds exception
      • setChildren

        void setChildren​(java.util.List<ITreeNode<T>> children)
        Sets the children.
        Parameters:
        children - the new children
      • setDisplayValue

        void setDisplayValue​(java.lang.String displayValue)
        Sets the optional display value.
        Parameters:
        displayValue - the new optional display value
      • setParent

        void setParent​(ITreeNode<T> parent)
        Sets the parent.
        Parameters:
        parent - the new parent
      • setValue

        void setValue​(T value)
        Sets the value.
        Parameters:
        value - the new value
      • toList

        default java.util.List<ITreeNode<T>> toList()
        To list.
        Returns:
        the list
      • traverse

        default void traverse​(ITreeNode<T> node,
                              java.util.List<ITreeNode<T>> list)
        Traverse.
        Parameters:
        node - the node
        list - the list