public class BaseSyncOptions<U,V>
extends java.lang.Object
| Modifier | Constructor and Description |
|---|---|
protected |
BaseSyncOptions(io.sphere.sdk.client.SphereClient ctpClient,
java.util.function.BiConsumer<java.lang.String,java.lang.Throwable> errorCallBack,
java.util.function.Consumer<java.lang.String> warningCallBack,
int batchSize,
boolean allowUuid,
TriFunction<java.util.List<io.sphere.sdk.commands.UpdateAction<U>>,V,U,java.util.List<io.sphere.sdk.commands.UpdateAction<U>>> beforeUpdateCallback,
java.util.function.Function<V,V> beforeCreateCallback) |
| Modifier and Type | Method and Description |
|---|---|
java.util.Optional<V> |
applyBeforeCreateCallBack(V newResourceDraft)
Given a new resource draft of type
V this method applies the beforeCreateCallback function
which is set to this instance of the BaseSyncOptions and returns the result. |
java.util.List<io.sphere.sdk.commands.UpdateAction<U>> |
applyBeforeUpdateCallBack(java.util.List<io.sphere.sdk.commands.UpdateAction<U>> updateActions,
V newResourceDraft,
U oldResource)
Given a
List of UpdateAction, a new resource draft of type V and the old existing
resource of the type U, this method applies the beforeUpdateCallback function
which is set to this instance of the BaseSyncOptions and returns the result. |
void |
applyErrorCallback(java.lang.String errorMessage) |
void |
applyErrorCallback(java.lang.String errorMessage,
java.lang.Throwable exception)
Given an
errorMessage and an exception, this method calls the errorCallback function
which is set to this instance of the BaseSyncOptions. |
void |
applyWarningCallback(java.lang.String warningMessage)
Given a
warningMessage string, this method calls the warningCallback function which is set
to this instance of the BaseSyncOptions. |
int |
getBatchSize()
Gets the batch size used in the sync process.
|
java.util.function.Function<V,V> |
getBeforeCreateCallback()
|
TriFunction<java.util.List<io.sphere.sdk.commands.UpdateAction<U>>,V,U,java.util.List<io.sphere.sdk.commands.UpdateAction<U>>> |
getBeforeUpdateCallback()
Returns the
beforeUpdateCallback TriFunction<List<UpdateAction<
U>>, V, U, List<UpdateAction<U>>> function
set to this BaseSyncOptions. |
io.sphere.sdk.client.SphereClient |
getCtpClient()
Returns the
SphereClient responsible for interaction with the target CTP project. |
java.util.function.BiConsumer<java.lang.String,java.lang.Throwable> |
getErrorCallBack()
|
java.util.function.Consumer<java.lang.String> |
getWarningCallBack()
|
boolean |
shouldAllowUuidKeys()
The sync expects the user to pass the keys to references in the
id field of References. |
protected BaseSyncOptions(@Nonnull
io.sphere.sdk.client.SphereClient ctpClient,
@Nullable
java.util.function.BiConsumer<java.lang.String,java.lang.Throwable> errorCallBack,
@Nullable
java.util.function.Consumer<java.lang.String> warningCallBack,
int batchSize,
boolean allowUuid,
@Nullable
TriFunction<java.util.List<io.sphere.sdk.commands.UpdateAction<U>>,V,U,java.util.List<io.sphere.sdk.commands.UpdateAction<U>>> beforeUpdateCallback,
@Nullable
java.util.function.Function<V,V> beforeCreateCallback)
public io.sphere.sdk.client.SphereClient getCtpClient()
SphereClient responsible for interaction with the target CTP project.SphereClient responsible for interaction with the target CTP project.@Nullable public java.util.function.BiConsumer<java.lang.String,java.lang.Throwable> getErrorCallBack()
errorCallback BiConsumer<String, Throwable> function set to
this BaseSyncOptions. It represents the callback that is called whenever an event occurs during
the sync process that represents an error.errorCallback BiConsumer<String, Throwable> function set to
this BaseSyncOptions@Nullable public java.util.function.Consumer<java.lang.String> getWarningCallBack()
warningCallback Consumer<String> function set to this
BaseSyncOptions. It represents the callback that is called whenever an event occurs
during the sync process that represents a warning.warningCallback Consumer<String> function set to this
BaseSyncOptionspublic void applyWarningCallback(@Nonnull
java.lang.String warningMessage)
warningMessage string, this method calls the warningCallback function which is set
to this instance of the BaseSyncOptions. If there warningCallback is null, this
method does nothing.warningMessage - the warning message to supply to the warningCallback function.public void applyErrorCallback(@Nonnull
java.lang.String errorMessage,
@Nullable
java.lang.Throwable exception)
errorMessage and an exception, this method calls the errorCallback function
which is set to this instance of the BaseSyncOptions. If there errorCallback is null,
this method does nothing.errorMessage - the error message to supply as first param to the errorCallback function.exception - optional Throwable instance to supply to the errorCallback function as a
second param.public void applyErrorCallback(@Nonnull
java.lang.String errorMessage)
errorMessage - the error message to supply as first param to the errorCallback function.applyErrorCallback(String, Throwable)public boolean shouldAllowUuidKeys()
id field of References. If the key values
are in UUID format, then this flag must be set to true, otherwise the sync will fail to resolve the reference.
This flag, if set to true, enables the user to use keys with UUID format. By default, it is set to false.boolean flag, if set to true, enables the user to use keys with UUID format for references.
By default, it is set to false.public int getBatchSize()
This batch size is set to 30 by default.
@Nullable public TriFunction<java.util.List<io.sphere.sdk.commands.UpdateAction<U>>,V,U,java.util.List<io.sphere.sdk.commands.UpdateAction<U>>> getBeforeUpdateCallback()
beforeUpdateCallback TriFunction<List<UpdateAction<
U>>, V, U, List<UpdateAction<U>>> function
set to this BaseSyncOptions. It represents a callback function which is applied (if set) on the
generated list of update actions to produce a resultant list after the filter function has been applied.beforeUpdateCallback TriFunction<List<UpdateAction<
U>>, V, U, List<UpdateAction<U>>>
function set to this BaseSyncOptions.@Nullable public java.util.function.Function<V,V> getBeforeCreateCallback()
beforeCreateCallback Function<V, Optional<V>>
function set to this BaseSyncOptions. It represents a callback function which is applied (if set)
on the resource draft of type V before it is created to produce a resultant draft after the filter
function has been applied.beforeUpdateCallback Function<V, Optional<V>>
function set to this BaseSyncOptions.@Nonnull public java.util.List<io.sphere.sdk.commands.UpdateAction<U>> applyBeforeUpdateCallBack(@Nonnull java.util.List<io.sphere.sdk.commands.UpdateAction<U>> updateActions, @Nonnull V newResourceDraft, @Nonnull U oldResource)
List of UpdateAction, a new resource draft of type V and the old existing
resource of the type U, this method applies the beforeUpdateCallback function
which is set to this instance of the BaseSyncOptions and returns the result. If the
beforeUpdateCallback is null, this method does nothing to the supplied list of update actions and returns
the same list. If the result of the callback is null, an empty list is returned.updateActions - the list of update actions to apply the beforeUpdateCallback function on.newResourceDraft - the new resource draft that is being compared to the old resource.oldResource - the old resource that is being compared to the new draft.beforeUpdateCallback function on. If the
beforeUpdateCallback function was null, the supplied list of updateActions is returned as
is. If the return of the callback was null, an empty list is returned.@Nonnull public java.util.Optional<V> applyBeforeCreateCallBack(@Nonnull V newResourceDraft)
V this method applies the beforeCreateCallback function
which is set to this instance of the BaseSyncOptions and returns the result.
beforeCreateCallback is null, this method does nothing to the supplied resource draft and
returns it as is, wrapped in an optional.beforeCreateCallback is null, an empty optional is returned.beforeCreateCallback is returned in the optional.newResourceDraft - the new resource draft that should be created.beforeCreateCallback
function on. If the beforeCreateCallback function was null, the supplied resource draft is
returned as is, wrapped in an optional.