Class DataViewUtils

java.lang.Object
com.vaadin.flow.data.provider.DataViewUtils

public final class DataViewUtils extends Object
Internal utility class used by data view implementations and components to simplify the filtering and sorting handling, but not limited to it.
Since:
Author:
Vaadin Ltd
  • Method Details

    • getComponentFilter

      public static <T> Optional<SerializablePredicate<T>> getComponentFilter(Component component)
      Gets the in-memory filter of a given component instance.
      Type Parameters:
      T - item type
      Parameters:
      component - component instance the filter is bound to
      Returns:
      optional component's in-memory filter.
    • getComponentSortComparator

      public static <T> Optional<SerializableComparator<T>> getComponentSortComparator(Component component)
      Gets the in-memory sort comparator of a given component instance.
      Type Parameters:
      T - item type
      Parameters:
      component - component instance the sort comparator is bound to
      Returns:
      optional component's in-memory sort comparator.
    • setComponentFilter

      public static <T> void setComponentFilter(Component component, SerializablePredicate<T> filter)
      Sets the in-memory filter to a given component instance. The filter replaces any filter that has been set or added previously. null will clear all filters.
      Type Parameters:
      T - items type
      Parameters:
      component - component instance the filter is bound to
      filter - component's in-memory filter to be set, or null to clear any previously set filters
    • setComponentSortComparator

      public static <T> void setComponentSortComparator(Component component, SerializableComparator<T> sortComparator)
      Sets the in-memory sort comparator to a given component instance. The sort comparator replaces any sort comparator that has been set or added previously. null will clear all sort comparators.
      Type Parameters:
      T - items type
      Parameters:
      component - component instance the sort comparator is bound to
      sortComparator - component's in-memory sort comparator to be set, or null to clear any previously set sort comparators
    • removeComponentFilterAndSortComparator

      public static void removeComponentFilterAndSortComparator(Component component)
      Removes the in-memory filter and sort comparator from a given component instance.
      Parameters:
      component - component instance the filter and sort comparator are removed from
    • getQuery

      public static Query getQuery(Component component)
      Generates a data query with component's in-memory filter and sort comparator.
      Parameters:
      component - component instance the filter and sort comparator are bound to
      Returns:
      query instance
    • getQuery

      public static Query getQuery(Component component, boolean withSorting)
      Generates a data query with component's in-memory filter and sort comparator, which is optionally included if withSorting is set to true.
      Parameters:
      component - component instance the filter and sort comparator are bound to
      withSorting - if true, the component's sort comparator will be included in the query.
      Returns:
      query instance