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 Modifier and Type Method and 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 if
withSorting
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 typeParameters:
component
- component instance the filter is bound toReturns:
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 typeParameters:
component
- component instance the sort comparator is bound toReturns:
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 typeParameters:
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 typeParameters:
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 toReturns:
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 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
-
-