Class AbstractHierarchicalDataProvider<T,F>
java.lang.Object
com.vaadin.flow.data.provider.AbstractDataProvider<T,F>
com.vaadin.flow.data.provider.hierarchy.AbstractHierarchicalDataProvider<T,F>
- Type Parameters:
T- data typeF- filter type
- All Implemented Interfaces:
DataProvider<T,,F> HierarchicalDataProvider<T,,F> Serializable
- Direct Known Subclasses:
AbstractBackEndHierarchicalDataProvider,TreeDataProvider
public abstract class AbstractHierarchicalDataProvider<T,F>
extends AbstractDataProvider<T,F>
implements HierarchicalDataProvider<T,F>
Abstract hierarchical data provider implementation which takes care of item
refreshes and associated events.
- 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidrefreshItem(T item, boolean refreshChildren) Refreshes the given item and its children whenrefreshChildrenis true.Wraps this data provider to create a data provider that supports programmatically setting a filter but no filtering through the query.<Q,C> HierarchicalConfigurableFilterDataProvider <T, Q, C> withConfigurableFilter(SerializableBiFunction<Q, C, F> filterCombiner) Wraps this data provider to create a data provider that supports programmatically setting a filter that will be combined with a filter provided through the query.<C> HierarchicalDataProvider<T, C> withConvertedFilter(SerializableFunction<C, F> filterConverter) Wraps this data provider to create a data provider that uses a different filter type.Methods 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, isInMemory, refreshAll, refreshItemMethods inherited from interface com.vaadin.flow.data.provider.hierarchy.HierarchicalDataProvider
fetch, fetchChildren, getChildCount, getDepth, getHierarchyFormat, getItemIndex, getParent, hasChildren, size
-
Constructor Details
-
AbstractHierarchicalDataProvider
public AbstractHierarchicalDataProvider()
-
-
Method Details
-
refreshItem
Description copied from interface:DataProviderRefreshes the given item and its children whenrefreshChildrenis true.This method will reset the item's cached hierarchy which can cause a content shift if the item also contains expanded children: their descendants aren't guaranteed to be re-fetched eagerly if they aren't visible, which may affect the overall size of the rendered hierarchy, leading to content shifts.
This method is only supported for hierarchical data providers that use
HierarchicalDataProvider.HierarchyFormat.NESTED.- Specified by:
refreshItemin interfaceDataProvider<T,F> - Overrides:
refreshItemin classAbstractDataProvider<T,F> - Parameters:
item- the item to refreshrefreshChildren- whether or not to refresh child items- Throws:
UnsupportedOperationException- if the hierarchy format is notHierarchicalDataProvider.HierarchyFormat.NESTED
-
withConfigurableFilter
public <Q,C> HierarchicalConfigurableFilterDataProvider<T,Q, withConfigurableFilterC> (SerializableBiFunction<Q, C, F> filterCombiner) Description copied from interface:DataProviderWraps this data provider to create a data provider that supports programmatically setting a filter that will be combined with a filter provided through the query.- Specified by:
withConfigurableFilterin interfaceDataProvider<T,F> - Specified by:
withConfigurableFilterin interfaceHierarchicalDataProvider<T,F> - Type Parameters:
Q- the query filter typeC- the configurable filter type- Parameters:
filterCombiner- a callback for combining and the configured filter with the filter from the query to get a filter to pass to the wrapped provider. Either parameter might benull, but the callback will not be invoked at all if both would benull. Notnull.- Returns:
- a data provider with a configurable filter, not
null - See Also:
-
withConvertedFilter
public <C> HierarchicalDataProvider<T,C> withConvertedFilter(SerializableFunction<C, F> filterConverter) Description copied from interface:DataProviderWraps this data provider to create a data provider that uses a different filter type. This can be used for adapting this data provider to a filter type provided by a Component such as ComboBox.For example receiving a String from ComboBox and making a Predicate based on it:
DataProvider<Person, Predicate<Person>> dataProvider; // ComboBox uses String as the filter type DataProvider<Person, String> wrappedProvider = dataProvider .withConvertedFilter(filterText -> { Predicate<Person> predicate = person -> person.getName() .startsWith(filterText); return predicate; }); comboBox.setDataProvider(wrappedProvider);- Specified by:
withConvertedFilterin interfaceDataProvider<T,F> - Specified by:
withConvertedFilterin interfaceHierarchicalDataProvider<T,F> - Type Parameters:
C- the filter type that the wrapped data provider accepts; typically provided by a Component- Parameters:
filterConverter- callback that converts the filter in the query of the wrapped data provider into a filter supported by this data provider. Will only be called if the query contains a filter. Notnull- Returns:
- wrapped data provider, not
null
-
withConfigurableFilter
Description copied from interface:DataProviderWraps this data provider to create a data provider that supports programmatically setting a filter but no filtering through the query.- Specified by:
withConfigurableFilterin interfaceDataProvider<T,F> - Specified by:
withConfigurableFilterin interfaceHierarchicalDataProvider<T,F> - Returns:
- a data provider with a configurable filter, not
null - See Also:
-