public abstract class BaseSync<T,U extends BaseSyncStatistics,V extends BaseSyncOptions>
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected U |
statistics |
protected V |
syncOptions |
| Modifier | Constructor and Description |
|---|---|
protected |
BaseSync(U statistics,
V syncOptions) |
| Modifier and Type | Method and Description |
|---|---|
U |
getStatistics()
Returns an instance of type U which is a subclass of
BaseSyncStatistics containing all the stats of the
sync process; which includes a report message, the total number of update, created, failed, processed resources
and the processing time of the sync in different time units and in a human readable format. |
protected abstract java.util.concurrent.CompletionStage<U> |
process(java.util.List<T> resourceDrafts)
Given a list of resource (e.g.
|
protected abstract java.util.concurrent.CompletionStage<U> |
processBatch(java.util.List<T> batch) |
java.util.concurrent.CompletionStage<U> |
sync(java.util.List<T> resourceDrafts)
Given a list of resource (e.g.
|
protected abstract java.util.concurrent.CompletionStage<U> |
syncBatches(java.util.List<java.util.List<T>> batches,
java.util.concurrent.CompletionStage<U> result)
Given a list of resource (e.g.
|
protected final U extends BaseSyncStatistics statistics
protected final V extends BaseSyncOptions syncOptions
protected abstract java.util.concurrent.CompletionStage<U> process(@Nonnull java.util.List<T> resourceDrafts)
resourceDrafts - the list of new resources as drafts.CompletionStage<U> which contains as a result an instance of
U which is a subclass of BaseSyncStatistics representing the statistics instance
attribute of this BaseSync.public java.util.concurrent.CompletionStage<U> sync(@Nonnull java.util.List<T> resourceDrafts)
The time before and after the actual sync process starts is recorded in the BaseSyncStatistics
container so that the total processing time is computed in the statistics.
resourceDrafts - the list of new resources as drafts.CompletionStage<U> which contains as a result an instance of
U which is a subclass of BaseSyncStatistics representing the statistics instance
attribute of this BaseSync.@Nonnull public U getStatistics()
BaseSyncStatistics containing all the stats of the
sync process; which includes a report message, the total number of update, created, failed, processed resources
and the processing time of the sync in different time units and in a human readable format.protected abstract java.util.concurrent.CompletionStage<U> syncBatches(@Nonnull java.util.List<java.util.List<T>> batches, @Nonnull java.util.concurrent.CompletionStage<U> result)
List<List> of resources, this method recursively calls
processBatch(List) on each batch, then removes it, until there are no more batches, in other words,
all batches have been synced.batches - the batches of resources to sync.result - in the first call of this recursive method, this result is normally a completed future, it
used from within the method to recursively sync each batch once the previous batch has
finished syncing.CompletionStage<U> which contains as a result an instance of
BaseSyncStatistics representing the statistics of the sync process executed on the
given list of batches.