public abstract class BaseSyncOptionsBuilder<T extends BaseSyncOptionsBuilder<T,S,U,V,A>,S extends BaseSyncOptions,U,V,A>
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected int |
batchSize |
protected java.util.function.Function<V,V> |
beforeCreateCallback |
protected TriFunction<java.util.List<io.sphere.sdk.commands.UpdateAction<A>>,V,U,java.util.List<io.sphere.sdk.commands.UpdateAction<A>>> |
beforeUpdateCallback |
protected long |
cacheSize |
protected io.sphere.sdk.client.SphereClient |
ctpClient |
protected QuadConsumer<SyncException,java.util.Optional<V>,java.util.Optional<U>,java.util.List<io.sphere.sdk.commands.UpdateAction<A>>> |
errorCallback |
protected TriConsumer<SyncException,java.util.Optional<V>,java.util.Optional<U>> |
warningCallback |
Constructor and Description |
---|
BaseSyncOptionsBuilder() |
Modifier and Type | Method and Description |
---|---|
T |
batchSize(int batchSize)
Set option that indicates batch size for sync process.
|
T |
beforeCreateCallback(java.util.function.Function<V,V> beforeCreateCallback)
Sets the beforeCreateCallback
Function which can be applied on a new resource draft of
type V (e.g. |
T |
beforeUpdateCallback(TriFunction<java.util.List<io.sphere.sdk.commands.UpdateAction<A>>,V,U,java.util.List<io.sphere.sdk.commands.UpdateAction<A>>> beforeUpdateCallback)
Sets the beforeUpdateCallback
TriFunction which can be applied on the supplied list of
update actions generated from comparing an old resource of type U (e.g. |
protected abstract S |
build()
Creates new instance of
S which extends BaseSyncOptions enriched with all
attributes provided to this builder. |
T |
cacheSize(long cacheSize)
Sets the cache size that indicates the key to id cache size of the sync process.
|
T |
errorCallback(QuadConsumer<SyncException,java.util.Optional<V>,java.util.Optional<U>,java.util.List<io.sphere.sdk.commands.UpdateAction<A>>> errorCallback)
Sets the
errorCallback function of the sync module. |
protected abstract T |
getThis()
|
T |
warningCallback(TriConsumer<SyncException,java.util.Optional<V>,java.util.Optional<U>> warningCallback)
Sets the
warningCallback function of the sync module. |
protected io.sphere.sdk.client.SphereClient ctpClient
protected QuadConsumer<SyncException,java.util.Optional<V>,java.util.Optional<U>,java.util.List<io.sphere.sdk.commands.UpdateAction<A>>> errorCallback
protected TriConsumer<SyncException,java.util.Optional<V>,java.util.Optional<U>> warningCallback
protected int batchSize
protected TriFunction<java.util.List<io.sphere.sdk.commands.UpdateAction<A>>,V,U,java.util.List<io.sphere.sdk.commands.UpdateAction<A>>> beforeUpdateCallback
protected long cacheSize
public T errorCallback(@Nonnull QuadConsumer<SyncException,java.util.Optional<V>,java.util.Optional<U>,java.util.List<io.sphere.sdk.commands.UpdateAction<A>>> errorCallback)
errorCallback
function of the sync module. This callback will be called
whenever an event occurs that leads to an error alert from the sync process.errorCallback
- the new value to set to the error callback.this
instance of BaseSyncOptionsBuilder
public T warningCallback(@Nonnull TriConsumer<SyncException,java.util.Optional<V>,java.util.Optional<U>> warningCallback)
warningCallback
function of the sync module. This callback will be called
whenever an event occurs that leads to a warning alert from the sync process.warningCallback
- the new value to set to the warning callback.this
instance of BaseSyncOptionsBuilder
public T batchSize(int batchSize)
This batch size is set to 30 by default.
batchSize
- int that indicates batch size of resources to process. Has to be positive or
else will be ignored and default value of 30 would be used.this
instance of BaseSyncOptionsBuilder
public T cacheSize(long cacheSize)
Note: This cache size is set to 10.000 by default.
cacheSize
- a long number value that indicates cache size of the key to id cache used for
reference resolution. Has to be positive or else will be ignored and default value of
10.000 would be used.this
instance of BaseSyncOptionsBuilder
public T beforeUpdateCallback(@Nonnull TriFunction<java.util.List<io.sphere.sdk.commands.UpdateAction<A>>,V,U,java.util.List<io.sphere.sdk.commands.UpdateAction<A>>> beforeUpdateCallback)
TriFunction
which can be applied on the supplied list of
update actions generated from comparing an old resource of type U
(e.g. Product
) to a new draft of type V
(e.g. ProductDraft
). It results in a resultant list after the specified
TriFunction
beforeUpdateCallback
function has been applied. This can be used to
intercept the sync process before issuing an update request and to be able to manipulate the
update actions. Note: Specifying a callback that returns a null
value or empty
list will skip issuing the update request.beforeUpdateCallback
- function which can be applied on generated list of update actions.this
instance of BaseSyncOptionsBuilder
public T beforeCreateCallback(@Nonnull java.util.function.Function<V,V> beforeCreateCallback)
Function
which can be applied on a new resource draft of
type V
(e.g. ProductDraft
) before it's created by the
sync. It results in a resource draft of the same type which is the result of the application of
the specified Function
beforeCreateCallback
function. This can be used to
intercept the sync process before creating the resource draft and to be able to manipulate it.
Note: Specifying a callback that returns a null
value will skip draft creation.beforeCreateCallback
- function which can be applied on a new draft before it's created by
the sync.this
instance of BaseSyncOptionsBuilder
protected abstract S build()
S
which extends BaseSyncOptions
enriched with all
attributes provided to this
builder.BaseSyncOptions
protected abstract T getThis()
this
instance of T
, which extends BaseSyncOptionsBuilder
. The
purpose of this method is to make sure that this
is an instance of a class which
extends BaseSyncOptionsBuilder
in order to be used in the generic methods of the class.
Otherwise, without this method, the methods above would need to cast this to T
which
could lead to a runtime error of the class was extended in a wrong way.