com.vaadin.data.provider.
Interface InMemoryDataProvider<T>
-
Type Parameters:
T
- data typeAll Superinterfaces:
ConfigurableFilterDataProvider<T,SerializablePredicate<T>,SerializablePredicate<T>>
,DataProvider<T,SerializablePredicate<T>>
,Serializable
All Known Implementing Classes:
public interface InMemoryDataProvider<T> extends ConfigurableFilterDataProvider<T,SerializablePredicate<T>,SerializablePredicate<T>>
A mixin interface for in-memory data providers. Contains methods for configuring sorting and filtering.
Since:
8.1
Author:
Vaadin Ltd
-
-
Method Summary
All Methods Modifier and Type Method Description default <V> void
addFilter(ValueProvider<T,V> valueProvider, SerializablePredicate<V> valueFilter)
Adds a filter for an item property.
default void
addFilter(SerializablePredicate<T> filter)
Adds a filter to be applied to all queries.
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
clearFilters()
Removes any filter that has been set or added previously.
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 <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> 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.
SerializablePredicate<T>
getFilter()
Gets the current filter of this data provider.
SerializableComparator<T>
getSortComparator()
Gets the current sort comparator of this data provider.
default boolean
isInMemory()
Gets whether the DataProvider content all available in memory or does it use some external backend.
default <V> void
setFilter(ValueProvider<T,V> valueProvider, SerializablePredicate<V> valueFilter)
Sets a filter for an item property.
void
setFilter(SerializablePredicate<T> filter)
Sets a filter to be applied to all queries.
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.data.provider.DataProvider
addDataProviderListener, fetch, getId, refreshAll, refreshItem, size, withConfigurableFilter, withConfigurableFilter, withConvertedFilter
-
-
-
-
Method Detail
-
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
void setFilter(SerializablePredicate<T> filter)
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 filtersSee Also:
setFilter(ValueProvider, SerializablePredicate)
,setFilterByValue(ValueProvider, Object)
,addFilter(SerializablePredicate)
-
setFilter
default <V> void setFilter(ValueProvider<T,V> valueProvider, SerializablePredicate<V> valueFilter)
Sets a filter for an item property. The filter replaces any filter that has been set or added previously.
Parameters:
valueProvider
- value provider that gets the property value, notnull
valueFilter
- filter for testing the property value, notnull
See Also:
setFilter(SerializablePredicate)
,setFilterByValue(ValueProvider, Object)
,addFilter(ValueProvider, SerializablePredicate)
-
addFilter
default void addFilter(SerializablePredicate<T> filter)
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(ValueProvider, SerializablePredicate)
,addFilterByValue(ValueProvider, Object)
,setFilter(SerializablePredicate)
-
addFilter
default <V> void addFilter(ValueProvider<T,V> valueProvider, SerializablePredicate<V> valueFilter)
Adds a filter for an item property. The filter will be used in addition to any filter that has been set or added previously.
Parameters:
valueProvider
- value provider that gets the property value, notnull
valueFilter
- filter for testing the property value, notnull
See Also:
addFilter(SerializablePredicate)
,addFilterByValue(ValueProvider, Object)
,setFilter(ValueProvider, SerializablePredicate)
-
setFilterByValue
default <V> void setFilterByValue(ValueProvider<T,V> valueProvider, V requiredValue)
Sets a filter that requires an item property to have a specific value. The property value and the provided value are compared using
Object.equals(Object)
. The filter replaces any filter that has been set or added previously.Parameters:
valueProvider
- value provider that gets the property value, notnull
requiredValue
- the value that the property must have for the filter to passSee Also:
setFilter(SerializablePredicate)
,setFilter(ValueProvider, SerializablePredicate)
,addFilterByValue(ValueProvider, Object)
-
addFilterByValue
default <V> void addFilterByValue(ValueProvider<T,V> valueProvider, V requiredValue)
Adds a filter that requires an item property to have a specific value. The property value and the provided value are compared using
Object.equals(Object)
.The filter will be used in addition to any filter that has been set or added previously.Parameters:
valueProvider
- value provider that gets the property value, notnull
requiredValue
- the value that the property must have for the filter to passSee Also:
setFilterByValue(ValueProvider, Object)
,addFilter(SerializablePredicate)
,addFilter(ValueProvider, SerializablePredicate)
-
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
void setSortComparator(SerializableComparator<T> comparator)
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 orderSee Also:
setSortOrder(ValueProvider, SortDirection)
,addSortComparator(SerializableComparator)
-
addSortComparator
default void addSortComparator(SerializableComparator<T> comparator)
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:
setSortComparator(SerializableComparator)
,addSortOrder(ValueProvider, SortDirection)
-
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.
Parameters:
valueProvider
- the value provider that defines the property do sort by, notnull
sortDirection
- the sort direction to use, notnull
See Also:
setSortComparator(SerializableComparator)
,addSortOrder(ValueProvider, SortDirection)
-
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.
Parameters:
valueProvider
- the value provider that defines the property do sort by, notnull
sortDirection
- the sort direction to use, notnull
See Also:
setSortOrder(ValueProvider, SortDirection)
,addSortComparator(SerializableComparator)
-
filteringBy
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.
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.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.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
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. Equality is tested using
Objects.equals(Object, Object)
.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 is
null
.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
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. Conversion to lower case is done using the locale of the
current 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 is
null
.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
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. Conversion to lower case is done using the locale of the
current 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
-
-