T
- data provider data typeF
- data provider filter typepublic class CallbackDataProvider<T,F> extends AbstractBackEndDataProvider<T,F>
Modifier and Type | Class and 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 and 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.
|
Modifier and Type | Method and 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.
|
fetch, setSortOrders, size
addDataProviderListener, addListener, fireEvent, refreshAll, refreshItem, refreshItem
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
isInMemory, setSortOrder, setSortOrders
addDataProviderListener, fromCallbacks, fromFilteringCallbacks, fromStream, ofCollection, ofItems, refreshAll, refreshItem, refreshItem, withConfigurableFilter, withConfigurableFilter, withConvertedFilter
public CallbackDataProvider(CallbackDataProvider.FetchCallback<T,F> fetchCallback, CallbackDataProvider.CountCallback<T,F> countCallback)
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
queryCallbackDataProvider(FetchCallback, CountCallback, ValueProvider)
public CallbackDataProvider(CallbackDataProvider.FetchCallback<T,F> fetchCallBack, CallbackDataProvider.CountCallback<T,F> countCallback, ValueProvider<T,Object> identifierGetter)
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 itempublic Stream<T> fetchFromBackEnd(Query<T,F> query)
AbstractBackEndDataProvider
fetchFromBackEnd
in class AbstractBackEndDataProvider<T,F>
query
- the query that defines sorting, filtering and paging for
fetching the dataprotected int sizeInBackEnd(Query<T,F> query)
AbstractBackEndDataProvider
sizeInBackEnd
in class AbstractBackEndDataProvider<T,F>
query
- the query that defines filtering to be used for counting the
number of itemspublic Object getId(T item)
DataProvider
Default is to use item itself as its own identifier. If the item has
Object.equals(Object)
and Object.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.
item
- the item to get identifier for; not null
null
Copyright © 2022. All rights reserved.