Interface InMemoryDataProvider<T>
- Type Parameters:
T
- data type
- All Superinterfaces:
ConfigurableFilterDataProvider<T,
,SerializablePredicate<T>, SerializablePredicate<T>> DataProvider<T,
,SerializablePredicate<T>> Serializable
- All Known Implementing Classes:
DataCommunicator.EmptyDataProvider
,ListDataProvider
,TreeDataProvider
- Since:
- 1.0
- Author:
- Vaadin Ltd
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
addFilter
(SerializablePredicate<T> filter) Adds a filter to be applied to all queries.default <V> void
addFilter
(ValueProvider<T, V> valueProvider, SerializablePredicate<V> valueFilter) Adds a filter for an item property.default <V> void
addFilterByValue
(ValueProvider<T, V> valueProvider, V requiredValue) Adds a filter that requires an item property to have a specific value.default void
addSortComparator
(SerializableComparator<T> comparator) Adds a comparator to the default sorting for this data provider.default <V extends Comparable<? super V>>
voidaddSortOrder
(ValueProvider<T, V> valueProvider, SortDirection sortDirection) Adds a property and direction to the default sorting for this data provider.default void
Removes any filter that has been set or added previously.default <Q> DataProvider<T,
Q> filteringBy
(SerializableBiPredicate<T, Q> predicate) Wraps this data provider to create a new data provider that is filtered by comparing an item to the filter value provided in the query.default <V,
Q> DataProvider<T, Q> filteringBy
(ValueProvider<T, V> valueProvider, SerializableBiPredicate<V, Q> predicate) Wraps this data provider to create a new data provider that is filtered by comparing an item property value to the filter value provided in the query.default <V> DataProvider<T,
V> filteringByEquals
(ValueProvider<T, V> valueProvider) Wraps this data provider to create a new data provider that is filtered by testing whether the value of a property is equals to the filter value provided in the query.default DataProvider<T,
String> filteringByPrefix
(ValueProvider<T, String> valueProvider) Wraps this data provider to create a new data provider that is filtered by a string by checking whether the lower case representation of an item property value starts with the lower case representation of the filter value provided in the query.default DataProvider<T,
String> filteringByPrefix
(ValueProvider<T, String> valueProvider, Locale locale) Wraps this data provider to create a new data provider that is filtered by a string by checking whether the lower case representation of an item property value starts with the lower case representation of the filter value provided in the query.default DataProvider<T,
String> filteringBySubstring
(ValueProvider<T, String> valueProvider) Wraps this data provider to create a new data provider that is filtered by a string by checking whether the lower case representation of the filter value provided in the query is a substring of the lower case representation of an item property value.default DataProvider<T,
String> filteringBySubstring
(ValueProvider<T, String> valueProvider, Locale locale) Wraps this data provider to create a new data provider that is filtered by a string by checking whether the lower case representation of the filter value provided in the query is a substring of the lower case representation of an item property value.Gets the current filter of this data provider.Gets the current sort comparator of this data provider.default boolean
Gets whether the DataProvider content all available in memory or does it use some external backend.void
setFilter
(SerializablePredicate<T> filter) Sets a filter to be applied to all queries.default <V> void
setFilter
(ValueProvider<T, V> valueProvider, SerializablePredicate<V> valueFilter) Sets a filter for an item property.default <V> void
setFilterByValue
(ValueProvider<T, V> valueProvider, V requiredValue) Sets a filter that requires an item property to have a specific value.void
setSortComparator
(SerializableComparator<T> comparator) Sets the comparator to use as the default sorting for this data provider.default <V extends Comparable<? super V>>
voidsetSortOrder
(ValueProvider<T, V> valueProvider, SortDirection sortDirection) Sets the property and direction to use as the default sorting for this data provider.Methods inherited from interface com.vaadin.flow.data.provider.DataProvider
addDataProviderListener, fetch, getId, refreshAll, refreshItem, refreshItem, size, withConfigurableFilter, withConfigurableFilter, withConvertedFilter
-
Method Details
-
isInMemory
default boolean isInMemory()Description copied from interface:DataProvider
Gets whether the DataProvider content all available in memory or does it use some external backend.- Specified by:
isInMemory
in interfaceDataProvider<T,
SerializablePredicate<T>> - Returns:
true
if all data is in memory;false
if not
-
getFilter
SerializablePredicate<T> getFilter()Gets the current filter of this data provider.- Returns:
- the filter of this data provider
-
setFilter
Sets a filter to be applied to all queries. The filter replaces any filter that has been set or added previously.- Specified by:
setFilter
in interfaceConfigurableFilterDataProvider<T,
SerializablePredicate<T>, SerializablePredicate<T>> - Parameters:
filter
- the filter to set, ornull
to remove any set filters- See Also:
-
setFilter
Sets a filter for an item property. The filter replaces any filter that has been set or added previously.- Type Parameters:
V
- the provided value type- Parameters:
valueProvider
- value provider that gets the property value, notnull
valueFilter
- filter for testing the property value, notnull
- See Also:
-
addFilter
Adds a filter to be applied to all queries. The filter will be used in addition to any filter that has been set or added previously.- Parameters:
filter
- the filter to add, notnull
- See Also:
-
addFilter
Adds a filter for an item property. The filter will be used in addition to any filter that has been set or added previously.- Type Parameters:
V
- the provided value type- Parameters:
valueProvider
- value provider that gets the property value, notnull
valueFilter
- filter for testing the property value, notnull
- See Also:
-
setFilterByValue
Sets a filter that requires an item property to have a specific value. The property value and the provided value are compared usingObject.equals(Object)
. The filter replaces any filter that has been set or added previously.- Type Parameters:
V
- the provided value type- Parameters:
valueProvider
- value provider that gets the property value, notnull
requiredValue
- the value that the property must have for the filter to pass- See Also:
-
addFilterByValue
Adds a filter that requires an item property to have a specific value. The property value and the provided value are compared usingObject.equals(Object)
.The filter will be used in addition to any filter that has been set or added previously.- Type Parameters:
V
- the provided value type- Parameters:
valueProvider
- value provider that gets the property value, notnull
requiredValue
- the value that the property must have for the filter to pass- See Also:
-
clearFilters
default void clearFilters()Removes any filter that has been set or added previously.- See Also:
-
getSortComparator
SerializableComparator<T> getSortComparator()Gets the current sort comparator of this data provider.- Returns:
- the sort comparator of this data provider
-
setSortComparator
Sets the comparator to use as the default sorting for this data provider. This overrides the sorting set by any other method that manipulates the default sorting of this data provider.The default sorting is used if the query defines no sorting. The default sorting is also used to determine the ordering of items that are considered equal by the sorting defined in the query.
- Parameters:
comparator
- a comparator to use, ornull
to clear any previously set sort order- See Also:
-
addSortComparator
Adds a comparator to the default sorting for this data provider. If no default sorting has been defined, then the provided comparator will be used as the default sorting. If a default sorting has been defined, then the provided comparator will be used to determine the ordering of items that are considered equal by the previously defined default sorting.The default sorting is used if the query defines no sorting. The default sorting is also used to determine the ordering of items that are considered equal by the sorting defined in the query.
- Parameters:
comparator
- a comparator to add, notnull
- See Also:
-
setSortOrder
default <V extends Comparable<? super V>> void setSortOrder(ValueProvider<T, V> valueProvider, SortDirection sortDirection) Sets the property and direction to use as the default sorting for this data provider. This overrides the sorting set by any other method that manipulates the default sorting of this data provider.The default sorting is used if the query defines no sorting. The default sorting is also used to determine the ordering of items that are considered equal by the sorting defined in the query.
- Type Parameters:
V
- the provided value type- Parameters:
valueProvider
- the value provider that defines the property do sort by, notnull
sortDirection
- the sort direction to use, notnull
- See Also:
-
addSortOrder
default <V extends Comparable<? super V>> void addSortOrder(ValueProvider<T, V> valueProvider, SortDirection sortDirection) Adds a property and direction to the default sorting for this data provider. If no default sorting has been defined, then the provided sort order will be used as the default sorting. If a default sorting has been defined, then the provided sort order will be used to determine the ordering of items that are considered equal by the previously defined default sorting.The default sorting is used if the query defines no sorting. The default sorting is also used to determine the ordering of items that are considered equal by the sorting defined in the query.
- Type Parameters:
V
- the provided value type- Parameters:
valueProvider
- the value provider that defines the property do sort by, notnull
sortDirection
- the sort direction to use, notnull
- See Also:
-
filteringBy
Wraps this data provider to create a new data provider that is filtered by comparing an item to the filter value provided in the query.The predicate receives the item as the first parameter and the query filter value as the second parameter, and should return
true
if the corresponding item should be included. The query filter value is nevernull
? all items are included without running the predicate if the query doesn't define any filter.- Type Parameters:
Q
- the filter type- Parameters:
predicate
- a predicate to use for comparing the item to the query filter, notnull
- Returns:
- a data provider that filters accordingly, not
null
-
filteringBy
default <V,Q> DataProvider<T,Q> filteringBy(ValueProvider<T, V> valueProvider, SerializableBiPredicate<V, Q> predicate) Wraps this data provider to create a new data provider that is filtered by comparing an item property value to the filter value provided in the query.The predicate receives the property value as the first parameter and the query filter value as the second parameter, and should return
true
if the corresponding item should be included. The query filter value is nevernull
? all items are included without running either callback if the query doesn't define any filter.- Type Parameters:
V
- the provided value typeQ
- the filter type- Parameters:
valueProvider
- a value provider that gets the property value, notnull
predicate
- a predicate to use for comparing the property value to the query filter, notnull
- Returns:
- a data provider that filters accordingly, not
null
-
filteringByEquals
Wraps this data provider to create a new data provider that is filtered by testing whether the value of a property is equals to the filter value provided in the query. Equality is tested usingObjects.equals(Object, Object)
.- Type Parameters:
V
- the provided value type- Parameters:
valueProvider
- a value provider that gets the property value, notnull
- Returns:
- a data provider that filters accordingly, not
null
-
filteringBySubstring
default DataProvider<T,String> filteringBySubstring(ValueProvider<T, String> valueProvider, Locale locale) Wraps this data provider to create a new data provider that is filtered by a string by checking whether the lower case representation of the filter value provided in the query is a substring of the lower case representation of an item property value. The filter never passes if the item property value isnull
.- Parameters:
valueProvider
- a value provider that gets the string property value, notnull
locale
- the locale to use for converting the strings to lower case, notnull
- Returns:
- a data provider that filters accordingly, not
null
-
filteringBySubstring
Wraps this data provider to create a new data provider that is filtered by a string by checking whether the lower case representation of the filter value provided in the query is a substring of the lower case representation of an item property value. Conversion to lower case is done using the locale of thecurrent UI
if available, or otherwisethe default locale
. The filter never passes if the item property value isnull
.- Parameters:
valueProvider
- a value provider that gets the string property value, notnull
- Returns:
- a data provider that filters accordingly, not
null
-
filteringByPrefix
default DataProvider<T,String> filteringByPrefix(ValueProvider<T, String> valueProvider, Locale locale) Wraps this data provider to create a new data provider that is filtered by a string by checking whether the lower case representation of an item property value starts with the lower case representation of the filter value provided in the query. The filter never passes if the item property value isnull
.- Parameters:
valueProvider
- a value provider that gets the string property value, notnull
locale
- the locale to use for converting the strings to lower case, notnull
- Returns:
- a data provider that filters accordingly, not
null
-
filteringByPrefix
Wraps this data provider to create a new data provider that is filtered by a string by checking whether the lower case representation of an item property value starts with the lower case representation of the filter value provided in the query. Conversion to lower case is done using the locale of thecurrent UI
if available, or otherwisethe default locale
. The filter never passes if the item property value isnull
.- Parameters:
valueProvider
- a value provider that gets the string property value, notnull
- Returns:
- a data provider that filters accordingly, not
null
-