Class TreeDataProvider<T>
- java.lang.Object
-
- com.vaadin.flow.data.provider.AbstractDataProvider<T,F>
-
- com.vaadin.flow.data.provider.hierarchy.AbstractHierarchicalDataProvider<T,SerializablePredicate<T>>
-
- com.vaadin.flow.data.provider.hierarchy.TreeDataProvider<T>
-
- Type Parameters:
T- data type
- All Implemented Interfaces:
ConfigurableFilterDataProvider<T,SerializablePredicate<T>,SerializablePredicate<T>>,DataProvider<T,SerializablePredicate<T>>,HierarchicalDataProvider<T,SerializablePredicate<T>>,InMemoryDataProvider<T>,Serializable
public class TreeDataProvider<T> extends AbstractHierarchicalDataProvider<T,SerializablePredicate<T>> implements InMemoryDataProvider<T>
An in-memory data provider for listing components that display hierarchical data. Uses an instance ofTreeDataas its source of data.- Since:
- 1.2
- Author:
- Vaadin Ltd
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description TreeDataProvider(TreeData<T> treeData)Constructs a new TreeDataProvider.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Stream<T>fetchChildren(HierarchicalQuery<T,SerializablePredicate<T>> query)Fetches data from this HierarchicalDataProvider using givenquery.intgetChildCount(HierarchicalQuery<T,SerializablePredicate<T>> query)Get the number of immediate child data items for the parent item returned by a given query.SerializablePredicate<T>getFilter()Gets the current filter of this data provider.SerializableComparator<T>getSortComparator()Gets the current sort comparator of this data provider.TreeData<T>getTreeData()Return the underlying hierarchical data of this provider.booleanhasChildren(T item)Check whether a given item has any children associated with it.voidsetFilter(SerializablePredicate<T> filter)Sets a filter to be applied to all queries.voidsetSortComparator(SerializableComparator<T> comparator)Sets the comparator to use as the default sorting for this data provider.-
Methods inherited from class com.vaadin.flow.data.provider.hierarchy.AbstractHierarchicalDataProvider
withConfigurableFilter, withConfigurableFilter, withConvertedFilter
-
Methods inherited from class com.vaadin.flow.data.provider.AbstractDataProvider
addDataProviderListener, addListener, fireEvent, refreshAll, refreshItem, refreshItem
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.vaadin.flow.data.provider.DataProvider
addDataProviderListener, getId, refreshAll, refreshItem, refreshItem
-
Methods inherited from interface com.vaadin.flow.data.provider.hierarchy.HierarchicalDataProvider
fetch, size
-
Methods inherited from interface com.vaadin.flow.data.provider.InMemoryDataProvider
addFilter, addFilter, addFilterByValue, addSortComparator, addSortOrder, clearFilters, filteringBy, filteringBy, filteringByEquals, filteringByPrefix, filteringByPrefix, filteringBySubstring, filteringBySubstring, isInMemory, setFilter, setFilterByValue, setSortOrder
-
-
-
-
Method Detail
-
getTreeData
public TreeData<T> getTreeData()
Return the underlying hierarchical data of this provider.- Returns:
- the underlying data of this provider
-
hasChildren
public boolean hasChildren(T item)
Description copied from interface:HierarchicalDataProviderCheck whether a given item has any children associated with it.- Specified by:
hasChildrenin interfaceHierarchicalDataProvider<T,SerializablePredicate<T>>- Parameters:
item- the item to check for children- Returns:
- whether the given item has children
-
getChildCount
public int getChildCount(HierarchicalQuery<T,SerializablePredicate<T>> query)
Description copied from interface:HierarchicalDataProviderGet the number of immediate child data items for the parent item returned by a given query.- Specified by:
getChildCountin interfaceHierarchicalDataProvider<T,SerializablePredicate<T>>- Parameters:
query- given query to request the count for- Returns:
- the count of child data items for the data item
HierarchicalQuery.getParent()
-
fetchChildren
public Stream<T> fetchChildren(HierarchicalQuery<T,SerializablePredicate<T>> query)
Description copied from interface:HierarchicalDataProviderFetches data from this HierarchicalDataProvider using givenquery. Only the immediate children ofHierarchicalQuery.getParent()will be returned.- Specified by:
fetchChildrenin interfaceHierarchicalDataProvider<T,SerializablePredicate<T>>- Parameters:
query- given query to request data with- Returns:
- a stream of data objects resulting from the query
-
getFilter
public SerializablePredicate<T> getFilter()
Description copied from interface:InMemoryDataProviderGets the current filter of this data provider.- Specified by:
getFilterin interfaceInMemoryDataProvider<T>- Returns:
- the filter of this data provider
-
setFilter
public void setFilter(SerializablePredicate<T> filter)
Description copied from interface:InMemoryDataProviderSets a filter to be applied to all queries. The filter replaces any filter that has been set or added previously.- Specified by:
setFilterin interfaceConfigurableFilterDataProvider<T,SerializablePredicate<T>,SerializablePredicate<T>>- Specified by:
setFilterin interfaceInMemoryDataProvider<T>- Parameters:
filter- the filter to set, ornullto remove any set filters- See Also:
InMemoryDataProvider.setFilter(ValueProvider, SerializablePredicate),InMemoryDataProvider.setFilterByValue(ValueProvider, Object),InMemoryDataProvider.addFilter(SerializablePredicate)
-
getSortComparator
public SerializableComparator<T> getSortComparator()
Description copied from interface:InMemoryDataProviderGets the current sort comparator of this data provider.- Specified by:
getSortComparatorin interfaceInMemoryDataProvider<T>- Returns:
- the sort comparator of this data provider
-
setSortComparator
public void setSortComparator(SerializableComparator<T> comparator)
Description copied from interface:InMemoryDataProviderSets the comparator to use as the default sorting for this data provider. This overrides the sorting set by any other method that manipulates the default sorting of this data provider.The default sorting is used if the query defines no sorting. The default sorting is also used to determine the ordering of items that are considered equal by the sorting defined in the query.
- Specified by:
setSortComparatorin interfaceInMemoryDataProvider<T>- Parameters:
comparator- a comparator to use, ornullto clear any previously set sort order- See Also:
InMemoryDataProvider.setSortOrder(ValueProvider, SortDirection),InMemoryDataProvider.addSortComparator(SerializableComparator)
-
-