Interface ITree<V,​T>

  • Type Parameters:
    V - the generic type of the value
    T - the generic type of the concrete tree node
    All Superinterfaces:
    java.io.Serializable

    public interface ITree<V,​T>
    extends java.io.Serializable
    The interface ITree represents a generic tree structure
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void addChild​(T child)
      Adds the given child to this tree node
      void addChildren​(@NonNull java.util.Collection<T> children)
      Adds all the given children to this tree node
      void clearAll()
      Removes all the descendants from this tree node
      void clearChildren()
      Removes all the children from this tree node
      boolean contains​(T treeNode)
      Checks if the given ITree object is a descendant of this tree node
      boolean containsAll​(@NonNull java.util.Collection<T> treeNodes)
      Checks if the given Collection object of ITree objects are descendants of this tree node
      java.util.Collection<T> findAllByValue​(V value)
      Find all ITree objects that have the same value as the given value
      T findByValue​(V value)
      Find the first ITree object that have the same value as the given value
      java.util.Collection<T> getAllSiblings()
      Returns all siblings of this node in the parent's children list.
      int getChildCount()
      Gets the child count of this tree node
      java.util.Collection<T> getChildren()
      Gets the children of this tree node
      java.lang.String getDisplayValue()
      Gets the optional display value of this tree node
      int getLevel()
      Returns the distance from the root to this node.
      T getNextSibling()
      Returns the next sibling of this node in the parent's children list.
      T getParent()
      Gets the parent of this tree node
      T getPreviousSibling()
      Returns the previous sibling of this node in the parent's children list.
      T getRoot()
      Gets the root object
      V getValue()
      Gets the value of this tree node
      boolean hasChildren()
      Checks if this tree node has children
      boolean hasNextSibling()
      Checks if this node has a next sibling
      boolean hasParent()
      Checks if this tree node has a parent
      boolean hasPreviousSibling()
      Checks if this node has a previous sibling
      boolean isLeaf()
      Checks if this node is a leaf
      boolean isNode()
      Checks if this node is a node
      boolean isRoot()
      Checks if this ITree is the root ITree object
      void removeChild​(T child)
      Removes the given child from this tree node
      void removeChildren()
      Removes all the children from this tree node
      void removeChildren​(@NonNull java.util.Collection<T> children)
      Removes all the given children from this tree node
      void setChildren​(java.util.Collection<T> children)
      Sets the children of this tree node
      void setDisplayValue​(java.lang.String displayValue)
      Sets the optional display value of this tree node
      void setLeaf​(boolean leaf)
      Sets the flag that indicates if this tree node is a node or a leaf
      void setParent​(T parent)
      Sets the parent of this tree node
      void setValue​(V value)
      Sets the value of this tree node
      java.util.List<T> toList()
      Traverse this node and adds all descendant with this included in to a List object
      java.util.Collection<T> traverse()
      Traverse this node and adds all descendant with this included in to a Collection object
    • Method Detail

      • addChild

        void addChild​(T child)
        Adds the given child to this tree node
        Parameters:
        child - the child
      • addChildren

        void addChildren​(@NonNull
                         @NonNull java.util.Collection<T> children)
        Adds all the given children to this tree node
        Parameters:
        children - the children to add
      • getAllSiblings

        java.util.Collection<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
      • getPreviousSibling

        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
      • getNextSibling

        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
      • getChildCount

        int getChildCount()
        Gets the child count of this tree node
        Returns:
        the child count
      • getChildren

        java.util.Collection<T> getChildren()
        Gets the children of this tree node
        Returns:
        the children
      • setChildren

        void setChildren​(java.util.Collection<T> children)
        Sets the children of this tree node
        Parameters:
        children - the new children
      • getDisplayValue

        java.lang.String getDisplayValue()
        Gets the optional display value of this tree node
        Returns:
        the display value
      • setDisplayValue

        void setDisplayValue​(java.lang.String displayValue)
        Sets the optional display value of this tree node
        Parameters:
        displayValue - the new optional display value
      • getLevel

        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
      • getParent

        T getParent()
        Gets the parent of this tree node
        Returns:
        the parent
      • setParent

        void setParent​(T parent)
        Sets the parent of this tree node
        Parameters:
        parent - the new parent
      • getRoot

        T getRoot()
        Gets the root object
        Returns:
        the root object
      • getValue

        V getValue()
        Gets the value of this tree node
        Returns:
        the value
      • setValue

        void setValue​(V value)
        Sets the value of this tree node
        Parameters:
        value - the new value
      • hasChildren

        boolean hasChildren()
        Checks if this tree node has children
        Returns:
        true, if successful
      • hasParent

        boolean hasParent()
        Checks if this tree node has a parent
        Returns:
        true, if successful
      • hasPreviousSibling

        boolean hasPreviousSibling()
        Checks if this node has a previous sibling
        Returns:
        true, if successful
      • hasNextSibling

        boolean hasNextSibling()
        Checks if this node has a next sibling
        Returns:
        true, if successful
      • isLeaf

        boolean isLeaf()
        Checks if this node is a leaf
        Returns:
        true, if this node is a leaf
      • setLeaf

        void setLeaf​(boolean leaf)
        Sets the flag that indicates if this tree node is a node or a leaf
        Parameters:
        leaf - The flag to set that indicates if this tree node is a node or a leaf
      • isNode

        boolean isNode()
        Checks if this node is a node
        Returns:
        true, if this node is a node
      • isRoot

        boolean isRoot()
        Checks if this ITree is the root ITree object
        Returns:
        true, if this ITree is the root ITree object
      • removeChild

        void removeChild​(T child)
        Removes the given child from this tree node
        Parameters:
        child - the child
      • clearChildren

        void clearChildren()
        Removes all the children from this tree node
      • clearAll

        void clearAll()
        Removes all the descendants from this tree node
      • removeChildren

        void removeChildren()
        Removes all the children from this tree node
      • removeChildren

        void removeChildren​(@NonNull
                            @NonNull java.util.Collection<T> children)
        Removes all the given children from this tree node
        Parameters:
        children - the children to remove
      • findAllByValue

        java.util.Collection<T> findAllByValue​(V value)
        Find all ITree objects that have the same value as the given value
        Parameters:
        value - the value for the search process
        Returns:
        a Collection object with all found occurrences that have the same value as the given value
      • findByValue

        T findByValue​(@NonNull
                      V value)
        Find the first ITree object that have the same value as the given value
        Parameters:
        value - the value for the search process
        Returns:
        the first ITree object that have the same value as the given value
      • contains

        boolean contains​(T treeNode)
        Checks if the given ITree object is a descendant of this tree node
        Parameters:
        treeNode - the tree node to check
        Returns:
        true if the given ITree object is a descendant of this tree node otherwise false
      • containsAll

        boolean containsAll​(@NonNull
                            @NonNull java.util.Collection<T> treeNodes)
        Checks if the given Collection object of ITree objects are descendants of this tree node
        Parameters:
        treeNodes - the tree nodes
        Returns:
        true if the given Collection of tree node objects are descendants of this tree node otherwise false
      • toList

        java.util.List<T> toList()
        Traverse this node and adds all descendant with this included in to a List object
        Returns:
        a List object with this node and add all descendant
      • traverse

        java.util.Collection<T> traverse()
        Traverse this node and adds all descendant with this included in to a Collection object
        Returns:
        a Collection object with this node and add all descendant