T - data typepublic class ListDataProvider<T> extends AbstractDataProvider<T,SerializablePredicate<T>> implements ConfigurableFilterDataProvider<T,SerializablePredicate<T>,SerializablePredicate<T>>
| Constructor and Description |
|---|
ListDataProvider(Collection<T> items)
Constructs a new ListDataProvider.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addFilter(SerializablePredicate<T> filter)
Adds a filter to be applied to all queries.
|
<V> void |
addFilter(ValueProvider<T,V> valueProvider,
SerializablePredicate<V> valueFilter)
Adds a filter for an item property.
|
<V> void |
addFilterByValue(ValueProvider<T,V> valueProvider,
V requiredValue)
Adds a filter that requires an item property to have a specific value.
|
void |
addSortComparator(SerializableComparator<T> comparator)
Adds a comparator to the default sorting for this data provider.
|
<V extends Comparable<? super V>> |
addSortOrder(ValueProvider<T,V> valueProvider,
SortDirection sortDirection)
Adds a property and direction to the default sorting for this data
provider.
|
void |
clearFilters()
Removes any filter that has been set or added previously.
|
Stream<T> |
fetch(Query<T,SerializablePredicate<T>> query)
Fetches data from this DataProvider using given
query. |
<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.
|
<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.
|
<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.
|
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.
|
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.
|
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.
|
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.
|
Collection<T> |
getItems()
Returns the underlying data items.
|
boolean |
isInMemory()
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.
|
<V> void |
setFilter(ValueProvider<T,V> valueProvider,
SerializablePredicate<V> valueFilter)
Sets a filter for an item property.
|
<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.
|
<V extends Comparable<? super V>> |
setSortOrder(ValueProvider<T,V> valueProvider,
SortDirection sortDirection)
Sets the property and direction to use as the default sorting for this
data provider.
|
int |
size(Query<T,SerializablePredicate<T>> query)
Gets the amount of data in this DataProvider.
|
addDataProviderListener, addListener, fireEvent, refreshAll, refreshItemclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddDataProviderListener, fromCallbacks, fromFilteringCallbacks, fromStream, getId, ofCollection, ofItems, refreshAll, refreshItem, withConfigurableFilter, withConfigurableFilter, withConvertedFilterpublic ListDataProvider(Collection<T> items)
No protective copy is made of the list, and changes in the provided backing Collection will be visible via this data provider. The caller should copy the list if necessary.
items - the initial data, not nullpublic Collection<T> getItems()
public Stream<T> fetch(Query<T,SerializablePredicate<T>> query)
DataProviderquery.fetch in interface DataProvider<T,SerializablePredicate<T>>query - given query to request datanullpublic boolean isInMemory()
DataProviderisInMemory in interface DataProvider<T,SerializablePredicate<T>>true if all data is in memory; false if notpublic int size(Query<T,SerializablePredicate<T>> query)
DataProvidersize in interface DataProvider<T,SerializablePredicate<T>>query - query with sorting and filteringpublic void setSortComparator(SerializableComparator<T> comparator)
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.
comparator - a comparator to use, or null to clear any
previously set sort ordersetSortOrder(ValueProvider, SortDirection),
addSortComparator(SerializableComparator)public <V extends Comparable<? super V>> void setSortOrder(ValueProvider<T,V> valueProvider, SortDirection sortDirection)
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.
valueProvider - the value provider that defines the property do sort by, not
nullsortDirection - the sort direction to use, not nullsetSortComparator(SerializableComparator),
addSortOrder(ValueProvider, SortDirection)public void addSortComparator(SerializableComparator<T> comparator)
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.
comparator - a comparator to add, not nullsetSortComparator(SerializableComparator),
addSortOrder(ValueProvider, SortDirection)public <V extends Comparable<? super V>> void addSortOrder(ValueProvider<T,V> valueProvider, SortDirection sortDirection)
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.
valueProvider - the value provider that defines the property do sort by, not
nullsortDirection - the sort direction to use, not nullsetSortOrder(ValueProvider, SortDirection),
addSortComparator(SerializableComparator)public void setFilter(SerializablePredicate<T> filter)
setFilter in interface ConfigurableFilterDataProvider<T,SerializablePredicate<T>,SerializablePredicate<T>>filter - the filter to set, or null to remove any set
filterssetFilter(ValueProvider, SerializablePredicate),
setFilterByValue(ValueProvider, Object),
addFilter(SerializablePredicate)public void addFilter(SerializablePredicate<T> filter)
filter - the filter to add, not nulladdFilter(ValueProvider, SerializablePredicate),
addFilterByValue(ValueProvider, Object),
setFilter(SerializablePredicate)public void clearFilters()
setFilter(SerializablePredicate)public <V> void setFilter(ValueProvider<T,V> valueProvider, SerializablePredicate<V> valueFilter)
valueProvider - value provider that gets the property value, not
nullvalueFilter - filter for testing the property value, not nullsetFilter(SerializablePredicate),
setFilterByValue(ValueProvider, Object),
addFilter(ValueProvider, SerializablePredicate)public <V> void addFilter(ValueProvider<T,V> valueProvider, SerializablePredicate<V> valueFilter)
valueProvider - value provider that gets the property value, not
nullvalueFilter - filter for testing the property value, not nulladdFilter(SerializablePredicate),
addFilterByValue(ValueProvider, Object),
setFilter(ValueProvider, SerializablePredicate)public <V> void setFilterByValue(ValueProvider<T,V> valueProvider, V requiredValue)
Object.equals(Object). The filter replaces any filter that has
been set or added previously.valueProvider - value provider that gets the property value, not
nullrequiredValue - the value that the property must have for the filter to passsetFilter(SerializablePredicate),
setFilter(ValueProvider, SerializablePredicate),
addFilterByValue(ValueProvider, Object)public <V> void addFilterByValue(ValueProvider<T,V> valueProvider, V requiredValue)
Object.equals(Object).The filter will be used in addition to any
filter that has been set or added previously.valueProvider - value provider that gets the property value, not
nullrequiredValue - the value that the property must have for the filter to passsetFilterByValue(ValueProvider, Object),
addFilter(SerializablePredicate),
addFilter(ValueProvider, SerializablePredicate)public <Q> DataProvider<T,Q> filteringBy(SerializableBiPredicate<T,Q> predicate)
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
never null – all items are included without running the
predicate if the query doesn't define any filter.
predicate - a predicate to use for comparing the item to the query filter,
not nullnullpublic <V,Q> DataProvider<T,Q> filteringBy(ValueProvider<T,V> valueProvider, SerializableBiPredicate<V,Q> predicate)
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 never null – all items are included without
running either callback if the query doesn't define any filter.
valueProvider - a value provider that gets the property value, not
nullpredicate - a predicate to use for comparing the property value to the
query filter, not nullnullpublic <V> DataProvider<T,V> filteringByEquals(ValueProvider<T,V> valueProvider)
Objects.equals(Object, Object).valueProvider - a value provider that gets the property value, not
nullnullpublic DataProvider<T,String> filteringBySubstring(ValueProvider<T,String> valueProvider, Locale locale)
null.valueProvider - a value provider that gets the string property value, not
nulllocale - the locale to use for converting the strings to lower case,
not nullnullpublic DataProvider<T,String> filteringBySubstring(ValueProvider<T,String> valueProvider)
current UI if
available, or otherwise the default locale.
The filter never passes if the item property value is null.valueProvider - a value provider that gets the string property value, not
nullnullpublic DataProvider<T,String> filteringByPrefix(ValueProvider<T,String> valueProvider, Locale locale)
null.valueProvider - a value provider that gets the string property value, not
nulllocale - the locale to use for converting the strings to lower case,
not nullnullpublic DataProvider<T,String> filteringByPrefix(ValueProvider<T,String> valueProvider)
current UI if available, or
otherwise the default locale. The filter
never passes if the item property value is null.valueProvider - a value provider that gets the string property value, not
nullnullCopyright © 2017 Vaadin Ltd. All rights reserved.