Package org.apache.tapestry5.tree
Class DefaultTreeModel<T>
- java.lang.Object
-
- org.apache.tapestry5.tree.DefaultTreeModel<T>
-
- Type Parameters:
T
- the type of data in the tree
- All Implemented Interfaces:
TreeModel<T>
public class DefaultTreeModel<T> extends Object implements TreeModel<T>
A default implementation of TreeModel that starts with aValueEncoder
(for the element to string conversion), aTreeModelAdapter
, and a list of root nodes. This implementation is not thread safe.- Since:
- 5.3
-
-
Constructor Summary
Constructors Constructor Description DefaultTreeModel(ValueEncoder<T> encoder, TreeModelAdapter<T> adapter, List<T> roots)
Standard constructor.DefaultTreeModel(ValueEncoder<T> encoder, TreeModelAdapter<T> adapter, T root)
Creates a new model starting from a single root element.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TreeNode<T>
find(T element)
Recursively searches from the root nodes to find the tree node that matches the provided element.TreeNode<T>
getById(String id)
Locates a node in the tree by its unique id.List<TreeNode<T>>
getRootNodes()
Returns the node or nodes that are the top level of the tree.
-
-
-
Constructor Detail
-
DefaultTreeModel
public DefaultTreeModel(ValueEncoder<T> encoder, TreeModelAdapter<T> adapter, T root)
Creates a new model starting from a single root element.- Parameters:
encoder
- used to convert values to strings and vice-versaadapter
- adapts elements to the treeroot
- defines the root node of the model
-
DefaultTreeModel
public DefaultTreeModel(ValueEncoder<T> encoder, TreeModelAdapter<T> adapter, List<T> roots)
Standard constructor.- Parameters:
encoder
- used to convert values to strings and vice-versaadapter
- adapts elements to the treeroots
- defines the root nodes of the model
-
-
Method Detail
-
getRootNodes
public List<TreeNode<T>> getRootNodes()
Description copied from interface:TreeModel
Returns the node or nodes that are the top level of the tree.- Specified by:
getRootNodes
in interfaceTreeModel<T>
-
getById
public TreeNode<T> getById(String id)
Description copied from interface:TreeModel
Locates a node in the tree by its unique id.- Specified by:
getById
in interfaceTreeModel<T>
- See Also:
TreeNode.getId()
-
-