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 type
F - 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:
  • Constructor Details

    • AbstractHierarchicalDataProvider

      public AbstractHierarchicalDataProvider()
  • Method Details

    • refreshItem

      public void refreshItem(T item, boolean refreshChildren)
      Description copied from interface: DataProvider
      Refreshes the given item and its children when refreshChildren is 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:
      refreshItem in interface DataProvider<T,F>
      Overrides:
      refreshItem in class AbstractDataProvider<T,F>
      Parameters:
      item - the item to refresh
      refreshChildren - whether or not to refresh child items
      Throws:
      UnsupportedOperationException - if the hierarchy format is not HierarchicalDataProvider.HierarchyFormat.NESTED
    • withConfigurableFilter

      public <Q, C> HierarchicalConfigurableFilterDataProvider<T,Q,C> withConfigurableFilter(com.vaadin.flow.function.SerializableBiFunction<Q,C,F> filterCombiner)
      Description copied from interface: DataProvider
      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.
      Specified by:
      withConfigurableFilter in interface DataProvider<T,F>
      Specified by:
      withConfigurableFilter in interface HierarchicalDataProvider<T,F>
      Type Parameters:
      Q - the query filter type
      C - 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 be null, but the callback will not be invoked at all if both would be null. Not null.
      Returns:
      a data provider with a configurable filter, not null
      See Also:
    • withConvertedFilter

      public <C> HierarchicalDataProvider<T,C> withConvertedFilter(com.vaadin.flow.function.SerializableFunction<C,F> filterConverter)
      Description copied from interface: DataProvider
      Wraps 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:
      withConvertedFilter in interface DataProvider<T,F>
      Specified by:
      withConvertedFilter in interface HierarchicalDataProvider<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. Not null
      Returns:
      wrapped data provider, not null
    • withConfigurableFilter

      public HierarchicalConfigurableFilterDataProvider<T,Void,F> withConfigurableFilter()
      Description copied from interface: DataProvider
      Wraps this data provider to create a data provider that supports programmatically setting a filter but no filtering through the query.
      Specified by:
      withConfigurableFilter in interface DataProvider<T,F>
      Specified by:
      withConfigurableFilter in interface HierarchicalDataProvider<T,F>
      Returns:
      a data provider with a configurable filter, not null
      See Also: