Class AbstractTreeModel<T>

    • Constructor Detail

      • AbstractTreeModel

        public AbstractTreeModel()
    • Method Detail

      • createChildren

        protected abstract Collection<TreeModel<T>> createChildren()
        Returns a concrete (and usually empty) Collection instance which should hold the tree's children.
        Returns:
        A concrete (and usually empty) Collection instance which should hold the tree's children.
      • setData

        public void setData​(T data)
        Description copied from interface: TreeModel
        Sets the wrapped data of the current tree node.
        Specified by:
        setData in interface TreeModel<T>
        Parameters:
        data - The wrapped data of current tree node.
      • addChild

        public TreeModel<T> addChild​(T data)
        Description copied from interface: TreeModel
        Creates and adds a child tree node with the given wrapped data to the current tree node. It returns the newly created and added child tree node to ease further building.
        Specified by:
        addChild in interface TreeModel<T>
        Parameters:
        data - The wrapped data of the child tree node to be created and added.
        Returns:
        The newly created and added child tree node of the current tree node.
      • addChildNode

        public TreeModel<T> addChildNode​(TreeModel<T> child)
        Description copied from interface: TreeModel
        Adds the given child tree node to the current tree node. It returns the added child tree node to ease further building.
        Specified by:
        addChildNode in interface TreeModel<T>
        Parameters:
        child - The child tree node to be added.
        Returns:
        The same child treenode.
      • remove

        public TreeModel<T> remove()
        Description copied from interface: TreeModel
        Removes the current tree node from its parent, if any. It returns the parent to ease further building.
        Specified by:
        remove in interface TreeModel<T>
        Returns:
        The parent tree node of the current tree node.
      • getData

        public T getData()
        Description copied from interface: TreeModel
        Returns the wrapped data of the current tree node.
        Specified by:
        getData in interface TreeModel<T>
        Returns:
        The wrapped data of the current tree node.
      • getParent

        public TreeModel<T> getParent()
        Description copied from interface: TreeModel
        Returns the parent tree node of the current tree node. Returns null if there is none.
        Specified by:
        getParent in interface TreeModel<T>
        Returns:
        The parent tree node of the current tree node.
      • getNextSibling

        public TreeModel<T> getNextSibling()
        Description copied from interface: TreeModel
        Returns the next tree node sibling of the current tree node. Returns null if there is none.
        Specified by:
        getNextSibling in interface TreeModel<T>
        Returns:
        The next tree node sibling of the current tree node.
      • getPreviousSibling

        public TreeModel<T> getPreviousSibling()
        Description copied from interface: TreeModel
        Returns the previous tree node sibling of the current tree node. Returns null if there is none.
        Specified by:
        getPreviousSibling in interface TreeModel<T>
        Returns:
        The previous tree node sibling of the current tree node.
      • getChildCount

        public int getChildCount()
        Description copied from interface: TreeModel
        Returns the count of the children of the current tree node.
        Specified by:
        getChildCount in interface TreeModel<T>
        Returns:
        The count of the children of the current tree node.
      • getChildren

        public List<TreeModel<T>> getChildren()
        Description copied from interface: TreeModel
        Returns an unmodifiable list of all child tree nodes of the current tree node. Adding and removing elements is not supported on the list. Adding new children should be done by the TreeModel.addChild(Object) method on the tree node parent. Removing children should be done by the TreeModel.remove() method on the tree node itself.
        Specified by:
        getChildren in interface TreeModel<T>
        Returns:
        An unmodifiable list of all child tree nodes of the current tree node.
      • iterator

        public Iterator<TreeModel<T>> iterator()
        Description copied from interface: TreeModel
        Returns an unmodifiable iterator over the children of the current tree node. Adding/inserting/removing elements is not supported on the iterator.
        Specified by:
        iterator in interface Iterable<T>
        Specified by:
        iterator in interface TreeModel<T>
        Returns:
        An unmodifiable iterator over the children of the current tree node.
        See Also:
        Iterable
      • getLevel

        public int getLevel()
        Description copied from interface: TreeModel
        Returns the level of the current tree node. The root node has level 0.
        Specified by:
        getLevel in interface TreeModel<T>
        Returns:
        The level of the current tree node.
      • getIndex

        public String getIndex()
        Description copied from interface: TreeModel
        Returns the zero-based unique index of the current tree node. This is an underscore separated representation of the position of the node in the tree hierarchy. The root node has index of null. The first child has index 0. The second child of first child has index 0_1. The first child of second child of third child has index 2_1_0.
        Specified by:
        getIndex in interface TreeModel<T>
        Returns:
        The unique index of the current tree node.
      • isRoot

        public boolean isRoot()
        Description copied from interface: TreeModel
        Returns whether the current tree node is the root node. That is, when it has no parent.
        Specified by:
        isRoot in interface TreeModel<T>
        Returns:
        true if the current tree node is the root node, otherwise false.
      • isLeaf

        public boolean isLeaf()
        Description copied from interface: TreeModel
        Returns whether the current tree node is a leaf node. That is, when it has no children.
        Specified by:
        isLeaf in interface TreeModel<T>
        Returns:
        true if the current tree node is a leaf node, otherwise false.
      • isFirst

        public boolean isFirst()
        Description copied from interface: TreeModel
        Returns whether the current tree node is the first child of its parent, if any.
        Specified by:
        isFirst in interface TreeModel<T>
        Returns:
        true if the current tree node is the first child of its parent, otherwise false.
      • isLast

        public boolean isLast()
        Description copied from interface: TreeModel
        Returns whether the current tree node is the last child of its parent, if any.
        Specified by:
        isLast in interface TreeModel<T>
        Returns:
        true if the current tree node is the last child of its parent, otherwise false.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object