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 typeAll Implemented Interfaces:
BackEndDataProvider<T,F>
,DataProvider<T,F>
,Serializable
public class CallbackDataProvider<T,F> extends AbstractBackEndDataProvider<T,F>
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
Nested Classes Modifier and Type Class Description static interface
CallbackDataProvider.CountCallback<T,F>
Callback interface for counting the number of items in a backend based on a query.
static interface
CallbackDataProvider.FetchCallback<T,F>
Callback interface for fetching a stream of items from a backend based on a query.
-
Constructor Summary
Constructors Constructor Description 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.
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
All Methods Modifier and Type Method Description Stream<T>
fetchFromBackEnd(Query<T,F> query)
Fetches data from the back end using the given query.
Object
getId(T item)
Gets an identifier for the given item.
protected int
sizeInBackEnd(Query<T,F> query)
Counts the number of items available in the back end.
-
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, toString, 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 Detail
-
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 querySee Also:
CallbackDataProvider(FetchCallback, CountCallback, ValueProvider)
-
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 Detail
-
fetchFromBackEnd
public Stream<T> fetchFromBackEnd(Query<T,F> query)
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 dataReturns:
a stream of items matching the query
-
sizeInBackEnd
protected int sizeInBackEnd(Query<T,F> query)
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 itemsReturns:
the number of available items
-
getId
public Object getId(T item)
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
-
-