Package com.vaadin.flow.data.provider
Class DataViewUtils
java.lang.Object
com.vaadin.flow.data.provider.DataViewUtils
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 Summary
Modifier and TypeMethodDescriptionstatic <T> Optional<SerializablePredicate<T>>
getComponentFilter
(Component component) Gets the in-memory filter of a given component instance.static <T> Optional<SerializableComparator<T>>
getComponentSortComparator
(Component component) Gets the in-memory sort comparator of a given component instance.static Query
Generates a data query with component's in-memory filter and sort comparator.static Query
Generates a data query with component's in-memory filter and sort comparator, which is optionally included ifwithSorting
is set totrue
.static void
removeComponentFilterAndSortComparator
(Component component) Removes the in-memory filter and sort comparator from a given component instance.static <T> void
setComponentFilter
(Component component, SerializablePredicate<T> filter) Sets the in-memory filter to a given component instance.static <T> void
setComponentSortComparator
(Component component, SerializableComparator<T> sortComparator) Sets the in-memory sort comparator to a given component instance.
-
Method Details
-
getComponentFilter
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
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 tofilter
- component's in-memory filter to be set, ornull
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 tosortComparator
- component's in-memory sort comparator to be set, ornull
to clear any previously set sort comparators
-
removeComponentFilterAndSortComparator
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
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
Generates a data query with component's in-memory filter and sort comparator, which is optionally included ifwithSorting
is set totrue
.- Parameters:
component
- component instance the filter and sort comparator are bound towithSorting
- iftrue
, the component's sort comparator will be included in the query.- Returns:
- query instance
-