Package com.vaadin.flow.data.provider
Class CallbackDataProvider<T,F>
java.lang.Object
com.vaadin.flow.data.provider.AbstractDataProvider<T,F>
com.vaadin.flow.data.provider.AbstractBackEndDataProvider<T,F>
com.vaadin.flow.data.provider.CallbackDataProvider<T,F>
- Type Parameters:
T
- data provider data typeF
- data provider filter type
- All Implemented Interfaces:
BackEndDataProvider<T,
,F> DataProvider<T,
,F> Serializable
Data provider that uses one callback for fetching items from a back end and
another callback for counting the number of available items.
- Since:
- 1.0
- Author:
- Vaadin Ltd
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Callback interface for counting the number of items in a backend based on a query.static interface
Callback interface for fetching a stream of items from a backend based on a query. -
Constructor Summary
ConstructorDescriptionCallbackDataProvider
(CallbackDataProvider.FetchCallback<T, F> fetchCallback, CallbackDataProvider.CountCallback<T, F> countCallback) Constructs a new DataProvider to request data using callbacks for fetching and counting items in the back end.CallbackDataProvider
(CallbackDataProvider.FetchCallback<T, F> fetchCallBack, CallbackDataProvider.CountCallback<T, F> countCallback, ValueProvider<T, Object> identifierGetter) Constructs a new DataProvider to request data using callbacks for fetching and counting items in the back end. -
Method Summary
Modifier and TypeMethodDescriptionfetchFromBackEnd
(Query<T, F> query) Fetches data from the back end using the given query.Gets an identifier for the given item.protected int
sizeInBackEnd
(Query<T, F> query) Counts the number of items available in the back end.toString()
Methods inherited from class com.vaadin.flow.data.provider.AbstractBackEndDataProvider
fetch, setSortOrders, size
Methods inherited from class com.vaadin.flow.data.provider.AbstractDataProvider
addDataProviderListener, addListener, fireEvent, refreshAll, refreshItem, refreshItem
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.vaadin.flow.data.provider.BackEndDataProvider
isInMemory, setSortOrder, setSortOrders
Methods inherited from interface com.vaadin.flow.data.provider.DataProvider
addDataProviderListener, refreshAll, refreshItem, refreshItem, withConfigurableFilter, withConfigurableFilter, withConvertedFilter
-
Constructor Details
-
CallbackDataProvider
public CallbackDataProvider(CallbackDataProvider.FetchCallback<T, F> fetchCallback, CallbackDataProvider.CountCallback<T, F> countCallback) Constructs a new DataProvider to request data using callbacks for fetching and counting items in the back end.- Parameters:
fetchCallback
- function that returns a stream of items from the back end for a querycountCallback
- function that return the number of items in the back end for a query- See Also:
-
CallbackDataProvider
public CallbackDataProvider(CallbackDataProvider.FetchCallback<T, F> fetchCallBack, CallbackDataProvider.CountCallback<T, F> countCallback, ValueProvider<T, Object> identifierGetter) Constructs a new DataProvider to request data using callbacks for fetching and counting items in the back end.- Parameters:
fetchCallBack
- function that requests data from back end based on querycountCallback
- function that returns the amount of data in back end for queryidentifierGetter
- function that returns the identifier for a given item
-
-
Method Details
-
fetchFromBackEnd
Description copied from class:AbstractBackEndDataProvider
Fetches data from the back end using the given query.- Specified by:
fetchFromBackEnd
in classAbstractBackEndDataProvider<T,
F> - Parameters:
query
- the query that defines sorting, filtering and paging for fetching the data- Returns:
- a stream of items matching the query
-
sizeInBackEnd
Description copied from class:AbstractBackEndDataProvider
Counts the number of items available in the back end.- Specified by:
sizeInBackEnd
in classAbstractBackEndDataProvider<T,
F> - Parameters:
query
- the query that defines filtering to be used for counting the number of items- Returns:
- the number of available items
-
getId
Description copied from interface:DataProvider
Gets an identifier for the given item. This identifier is used by the framework to determine equality between two items.Default is to use item itself as its own identifier. If the item has
Object.equals(Object)
andObject.hashCode()
implemented in a way that it can be compared to other items, no changes are required.Note: This method will be called often by the Framework. It should not do any expensive operations.
- Parameters:
item
- the item to get identifier for; notnull
- Returns:
- the identifier for given item; not
null
-
toString
-