Class 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
TreeData as its source of data.- Since:
- 1.2
- Author:
- Vaadin Ltd
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.vaadin.flow.data.provider.hierarchy.HierarchicalDataProvider
HierarchicalDataProvider.HierarchyFormat -
Constructor Summary
ConstructorsConstructorDescriptionTreeDataProvider(TreeData<T> treeData) Constructs a new TreeDataProvider.TreeDataProvider(TreeData<T> treeData, HierarchicalDataProvider.HierarchyFormat hierarchyFormat) Creates a new TreeDataProvider and configures it to return the hierarchical data in the specified format:HierarchicalDataProvider.HierarchyFormat.NESTEDorHierarchicalDataProvider.HierarchyFormat.FLATTENED. -
Method Summary
Modifier and TypeMethodDescriptionFetches children based on the given hierarchical query.intGets the number of children based on the given hierarchical query.intGets the depth of a given item in the hierarchy, starting from zero (root).Gets the current filter of this data provider.Specifies the format in which the data provider returns hierarchical data.Gets the current sort comparator of this data provider.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
refreshItem, withConfigurableFilter, withConfigurableFilter, withConvertedFilterMethods inherited from class com.vaadin.flow.data.provider.AbstractDataProvider
addDataProviderListener, addListener, fireEvent, refreshAll, refreshItemMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.data.provider.DataProvider
addDataProviderListener, getId, refreshAll, refreshItem, refreshItemMethods inherited from interface com.vaadin.flow.data.provider.hierarchy.HierarchicalDataProvider
fetch, sizeMethods 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
-
Constructor Details
-
TreeDataProvider
Constructs a new TreeDataProvider.The data provider should be refreshed after making changes to the underlying
TreeDatainstance.- Parameters:
treeData- the backingTreeDatafor this provider, notnull
-
TreeDataProvider
public TreeDataProvider(TreeData<T> treeData, HierarchicalDataProvider.HierarchyFormat hierarchyFormat) Creates a new TreeDataProvider and configures it to return the hierarchical data in the specified format:HierarchicalDataProvider.HierarchyFormat.NESTEDorHierarchicalDataProvider.HierarchyFormat.FLATTENED.The data provider should be refreshed after making changes to the underlying
TreeDatainstance.- Parameters:
treeData- the backingTreeDatafor this provider, notnullhierarchyFormat- the hierarchy format to return data in, notnull
-
-
Method Details
-
getHierarchyFormat
Description copied from interface:HierarchicalDataProviderSpecifies the format in which the data provider returns hierarchical data. The default format isHierarchicalDataProvider.HierarchyFormat.NESTED.The component uses this method to determine how to fetch and render hierarchical data with this data provider.
- Specified by:
getHierarchyFormatin interfaceHierarchicalDataProvider<T,SerializablePredicate<T>> - Returns:
- the hierarchy format
-
getTreeData
Return the underlying hierarchical data of this provider.- Returns:
- the underlying data of this provider
-
hasChildren
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
-
getDepth
Description copied from interface:HierarchicalDataProviderGets the depth of a given item in the hierarchy, starting from zero (root).This method must be implemented for data providers that implement the flattened hierarchy format, see
HierarchicalDataProvider.getHierarchyFormat()andHierarchicalDataProvider.HierarchyFormat.FLATTENED.- Specified by:
getDepthin interfaceHierarchicalDataProvider<T,SerializablePredicate<T>> - Parameters:
item- the item to get the depth for- Returns:
- the depth of the item in the hierarchy
-
getChildCount
Description copied from interface:HierarchicalDataProviderGets the number of children based on the given hierarchical query.This method must be implemented in accordance with the selected hierarchy type, see
HierarchicalDataProvider.getHierarchyFormat()andHierarchicalDataProvider.HierarchyFormat.- Specified by:
getChildCountin interfaceHierarchicalDataProvider<T,SerializablePredicate<T>> - Parameters:
query- given query to request the count for- Returns:
- the count of children for the parent item or the root level if
the parent is
null
-
fetchChildren
Description copied from interface:HierarchicalDataProviderFetches children based on the given hierarchical query.This method must be implemented in accordance with the selected hierarchy type, see
HierarchicalDataProvider.getHierarchyFormat()andHierarchicalDataProvider.HierarchyFormat.- Specified by:
fetchChildrenin interfaceHierarchicalDataProvider<T,SerializablePredicate<T>> - Parameters:
query- given query to request data with- Returns:
- a stream of data objects for the
parent itemor the root level if the parent isnull, must not contain null values
-
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
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:
-
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
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:
-