Package org.omnifaces.model.tree
Class AbstractTreeModel<T>
- java.lang.Object
- 
- org.omnifaces.model.tree.AbstractTreeModel<T>
 
- 
- Type Parameters:
- T- The type of the wrapped data of the tree node.
 - All Implemented Interfaces:
- Serializable,- Iterable<TreeModel<T>>,- TreeModel<T>
 - Direct Known Subclasses:
- ListTreeModel,- SortedTreeModel
 
 public abstract class AbstractTreeModel<T> extends Object implements TreeModel<T> A base implementation ofTreeModel. Implementors basically only need to implementcreateChildren()wherein a concrete instance of the desired underlyingCollectionis returned.- Since:
- 1.7
- Author:
- Bauke Scholtz
- See Also:
- ListTreeModel,- SortedTreeModel, Serialized Form
 
- 
- 
Constructor SummaryConstructors Constructor Description AbstractTreeModel()
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description TreeModel<T>addChild(T data)Creates and adds a child tree node with the given wrapped data to the current tree node.TreeModel<T>addChildNode(TreeModel<T> child)Adds the given child tree node to the current tree node.protected abstract Collection<TreeModel<T>>createChildren()Returns a concrete (and usually empty)Collectioninstance which should hold the tree's children.booleanequals(Object object)intgetChildCount()Returns the count of the children of the current tree node.List<TreeModel<T>>getChildren()Returns an unmodifiable list of all child tree nodes of the current tree node.TgetData()Returns the wrapped data of the current tree node.StringgetIndex()Returns the zero-based unique index of the current tree node.intgetLevel()Returns the level of the current tree node.TreeModel<T>getNextSibling()Returns the next tree node sibling of the current tree node.TreeModel<T>getParent()Returns the parent tree node of the current tree node.TreeModel<T>getPreviousSibling()Returns the previous tree node sibling of the current tree node.inthashCode()booleanisFirst()Returns whether the current tree node is the first child of its parent, if any.booleanisLast()Returns whether the current tree node is the last child of its parent, if any.booleanisLeaf()Returns whether the current tree node is a leaf node.booleanisRoot()Returns whether the current tree node is the root node.Iterator<TreeModel<T>>iterator()Returns an unmodifiable iterator over the children of the current tree node.TreeModel<T>remove()Removes the current tree node from its parent, if any.voidsetData(T data)Sets the wrapped data of the current tree node.StringtoString()- 
Methods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, wait, wait, wait
 - 
Methods inherited from interface java.lang.IterableforEach, spliterator
 
- 
 
- 
- 
- 
Method Detail- 
createChildrenprotected abstract Collection<TreeModel<T>> createChildren() Returns a concrete (and usually empty)Collectioninstance which should hold the tree's children.- Returns:
- A concrete (and usually empty) Collectioninstance which should hold the tree's children.
 
 - 
setDatapublic void setData(T data) Description copied from interface:TreeModelSets the wrapped data of the current tree node.
 - 
addChildpublic TreeModel<T> addChild(T data) Description copied from interface:TreeModelCreates 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.
 - 
addChildNodepublic TreeModel<T> addChildNode(TreeModel<T> child) Description copied from interface:TreeModelAdds the given child tree node to the current tree node. It returns the added child tree node to ease further building.- Specified by:
- addChildNodein interface- TreeModel<T>
- Parameters:
- child- The child tree node to be added.
- Returns:
- The same child treenode.
 
 - 
removepublic TreeModel<T> remove() Description copied from interface:TreeModelRemoves the current tree node from its parent, if any. It returns the parent to ease further building.
 - 
getDatapublic T getData() Description copied from interface:TreeModelReturns the wrapped data of the current tree node.
 - 
getParentpublic TreeModel<T> getParent() Description copied from interface:TreeModelReturns the parent tree node of the current tree node. Returnsnullif there is none.
 - 
getNextSiblingpublic TreeModel<T> getNextSibling() Description copied from interface:TreeModelReturns the next tree node sibling of the current tree node. Returnsnullif there is none.- Specified by:
- getNextSiblingin interface- TreeModel<T>
- Returns:
- The next tree node sibling of the current tree node.
 
 - 
getPreviousSiblingpublic TreeModel<T> getPreviousSibling() Description copied from interface:TreeModelReturns the previous tree node sibling of the current tree node. Returnsnullif there is none.- Specified by:
- getPreviousSiblingin interface- TreeModel<T>
- Returns:
- The previous tree node sibling of the current tree node.
 
 - 
getChildCountpublic int getChildCount() Description copied from interface:TreeModelReturns the count of the children of the current tree node.- Specified by:
- getChildCountin interface- TreeModel<T>
- Returns:
- The count of the children of the current tree node.
 
 - 
getChildrenpublic List<TreeModel<T>> getChildren() Description copied from interface:TreeModelReturns 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 theTreeModel.addChild(Object)method on the tree node parent. Removing children should be done by theTreeModel.remove()method on the tree node itself.- Specified by:
- getChildrenin interface- TreeModel<T>
- Returns:
- An unmodifiable list of all child tree nodes of the current tree node.
 
 - 
iteratorpublic Iterator<TreeModel<T>> iterator() Description copied from interface:TreeModelReturns an unmodifiable iterator over the children of the current tree node. Adding/inserting/removing elements is not supported on the iterator.
 - 
getLevelpublic int getLevel() Description copied from interface:TreeModelReturns the level of the current tree node. The root node has level 0.
 - 
getIndexpublic String getIndex() Description copied from interface:TreeModelReturns 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 ofnull. The first child has index0. The second child of first child has index0_1. The first child of second child of third child has index2_1_0.
 - 
isRootpublic boolean isRoot() Description copied from interface:TreeModelReturns whether the current tree node is the root node. That is, when it has no parent.
 - 
isLeafpublic boolean isLeaf() Description copied from interface:TreeModelReturns whether the current tree node is a leaf node. That is, when it has no children.
 - 
isFirstpublic boolean isFirst() Description copied from interface:TreeModelReturns whether the current tree node is the first child of its parent, if any.
 - 
isLastpublic boolean isLast() Description copied from interface:TreeModelReturns whether the current tree node is the last child of its parent, if any.
 
- 
 
-