Package com.vaadin.flow.data.provider
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 Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <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
getQuery(Component component)
Generates a data query with component's in-memory filter and sort comparator.static Query
getQuery(Component component, boolean withSorting)
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 Detail
-
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 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
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 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
-
-