T
- the bean typepublic class DataCommunicator<T> extends Object implements Serializable
BiFunction
s)
to write JsonObject
s representing each data object to be sent to the
client-side.Constructor and Description |
---|
DataCommunicator(DataGenerator<T> dataGenerator,
ArrayUpdater arrayUpdater,
SerializableConsumer<elemental.json.JsonArray> dataUpdater,
StateNode stateNode)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
confirmUpdate(int updateId)
Confirm update with the given
updateId . |
protected Stream<T> |
fetchFromProvider(int offset,
int limit)
Fetches a list of items from the DataProvider.
|
List<QuerySortOrder> |
getBackEndSorting()
Returns the
QuerySortOrder to use with backend sorting. |
DataProvider<T,?> |
getDataProvider()
Gets the current data provider from this DataCommunicator.
|
protected int |
getDataProviderSize()
Getter method for finding the size of DataProvider.
|
protected Object |
getFilter()
Get the object used for filtering in this data communicator.
|
SerializableComparator<T> |
getInMemorySorting()
Returns the
Comparator to use with in-memory sorting. |
DataKeyMapper<T> |
getKeyMapper()
Gets the
DataKeyMapper used by this DataCommunicator . |
void |
refresh(T data)
Informs the DataCommunicator that a data object has been updated.
|
void |
reset()
Resets all the data.
|
void |
setBackEndSorting(List<QuerySortOrder> sortOrder)
Sets the
QuerySortOrder s to use with backend sorting. |
<F> SerializableConsumer<F> |
setDataProvider(DataProvider<T,F> dataProvider,
F initialFilter)
Sets the current data provider for this DataCommunicator.
|
void |
setInMemorySorting(SerializableComparator<T> comparator)
Sets the
Comparator to use with in-memory sorting. |
protected void |
setKeyMapper(DataKeyMapper<T> keyMapper)
Sets the
DataKeyMapper used in this DataCommunicator . |
void |
setRequestedRange(int start,
int length)
Sets the requested range of data to be sent.
|
public DataCommunicator(DataGenerator<T> dataGenerator, ArrayUpdater arrayUpdater, SerializableConsumer<elemental.json.JsonArray> dataUpdater, StateNode stateNode)
dataGenerator
- the data generator functionarrayUpdater
- array updater strategydataUpdater
- data updater strategystateNode
- the state node used to communicate forpublic void setRequestedRange(int start, int length)
start
- the start of the requested rangelength
- the end of the requested rangepublic void reset()
It effectively resends all available data.
public void refresh(T data)
data
- updated data object; not null
public void confirmUpdate(int updateId)
updateId
.updateId
- the update identifierpublic DataProvider<T,?> getDataProvider()
public <F> SerializableConsumer<F> setDataProvider(DataProvider<T,F> dataProvider, F initialFilter)
The returned consumer can be used to set some other filter value that should be included in queries sent to the data provider. It is only valid until another data provider is set.
F
- the filter typedataProvider
- the data provider to set, not null
initialFilter
- the initial filter value to use, or null
to not
use any initial filter valuepublic DataKeyMapper<T> getKeyMapper()
DataKeyMapper
used by this DataCommunicator
. Key
mapper can be used to map keys sent to the client-side back to their
respective data objects.protected void setKeyMapper(DataKeyMapper<T> keyMapper)
DataKeyMapper
used in this DataCommunicator
. Key
mapper can be used to map keys sent to the client-side back to their
respective data objects.keyMapper
- the keyMapperpublic void setInMemorySorting(SerializableComparator<T> comparator)
Comparator
to use with in-memory sorting.comparator
- comparator used to sort datapublic SerializableComparator<T> getInMemorySorting()
Comparator
to use with in-memory sorting.public void setBackEndSorting(List<QuerySortOrder> sortOrder)
QuerySortOrder
s to use with backend sorting.sortOrder
- list of sort order information to pass to a querypublic List<QuerySortOrder> getBackEndSorting()
QuerySortOrder
to use with backend sorting.protected int getDataProviderSize()
protected Object getFilter()
Copyright © 2019. All rights reserved.