U - Resource (e.g. ProductProjection, Category, etc..V - Resource Draft (e.g. ProductDraft, CategoryDraft, etcA - Resource to update (e.g. Product, Category, etc..public class BaseSyncOptions<U,V,A>
extends java.lang.Object
| Modifier | Constructor and Description |
|---|---|
protected |
BaseSyncOptions(io.sphere.sdk.client.SphereClient ctpClient,
QuadConsumer<SyncException,java.util.Optional<V>,java.util.Optional<U>,java.util.List<io.sphere.sdk.commands.UpdateAction<A>>> errorCallback,
TriConsumer<SyncException,java.util.Optional<V>,java.util.Optional<U>> warningCallback,
int batchSize,
TriFunction<java.util.List<io.sphere.sdk.commands.UpdateAction<A>>,V,U,java.util.List<io.sphere.sdk.commands.UpdateAction<A>>> beforeUpdateCallback,
java.util.function.Function<V,V> beforeCreateCallback,
long cacheSize) |
| 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<A>> |
applyBeforeUpdateCallback(java.util.List<io.sphere.sdk.commands.UpdateAction<A>> 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(SyncException syncException) |
void |
applyErrorCallback(SyncException exception,
U oldResource,
V newResourceDraft,
java.util.List<io.sphere.sdk.commands.UpdateAction<A>> updateActions)
Given an
errorMessage and an exception, this method calls the errorCallback function which is set to this instance of the BaseSyncOptions. |
void |
applyWarningCallback(SyncException exception,
U oldResource,
V newResourceDraft)
Given an
exception, oldResource and newResourceDraft 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<A>>,V,U,java.util.List<io.sphere.sdk.commands.UpdateAction<A>>> |
getBeforeUpdateCallback()
Returns the
beforeUpdateCallback TriFunction<List<UpdateAction< U>>, V, U, List<UpdateAction<U>>> function set to this BaseSyncOptions. |
long |
getCacheSize()
Gets the cache size used in the sync process.
|
io.sphere.sdk.client.SphereClient |
getCtpClient()
Returns the
SphereClient responsible for interaction with the target CTP project. |
QuadConsumer<SyncException,java.util.Optional<V>,java.util.Optional<U>,java.util.List<io.sphere.sdk.commands.UpdateAction<A>>> |
getErrorCallback()
Returns the
errorCallback QuadConsumer<SyncException, Optional<V>, Optional<U>, List<UpdateAction<U>>> function set to this BaseSyncOptions. |
TriConsumer<SyncException,java.util.Optional<V>,java.util.Optional<U>> |
getWarningCallback()
Returns the
warningCallback TriConsumer<SyncException, Optional<V>, Optional<U>> function set to this
BaseSyncOptions. |
protected BaseSyncOptions(@Nonnull
io.sphere.sdk.client.SphereClient ctpClient,
@Nullable
QuadConsumer<SyncException,java.util.Optional<V>,java.util.Optional<U>,java.util.List<io.sphere.sdk.commands.UpdateAction<A>>> errorCallback,
@Nullable
TriConsumer<SyncException,java.util.Optional<V>,java.util.Optional<U>> warningCallback,
int batchSize,
@Nullable
TriFunction<java.util.List<io.sphere.sdk.commands.UpdateAction<A>>,V,U,java.util.List<io.sphere.sdk.commands.UpdateAction<A>>> beforeUpdateCallback,
@Nullable
java.util.function.Function<V,V> beforeCreateCallback,
long cacheSize)
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 QuadConsumer<SyncException,java.util.Optional<V>,java.util.Optional<U>,java.util.List<io.sphere.sdk.commands.UpdateAction<A>>> getErrorCallback()
errorCallback QuadConsumer<SyncException, Optional<V>, Optional<U>, List<UpdateAction<U>>> 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 QuadConsumer<SyncException, Optional<V>, Optional<U>, List<UpdateAction<U>> function set to this BaseSyncOptions@Nullable public TriConsumer<SyncException,java.util.Optional<V>,java.util.Optional<U>> getWarningCallback()
warningCallback TriConsumer<SyncException, Optional<V>, Optional<U>> 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 TriConsumer<SyncException, Optional<V>, Optional<U>> function set to this BaseSyncOptionspublic void applyWarningCallback(@Nonnull
SyncException exception,
@Nullable
U oldResource,
@Nullable
V newResourceDraft)
exception, oldResource and newResourceDraft this method calls
the warningCallback function which is set to this instance of the BaseSyncOptions. If there warningCallback is null, this method does nothing.exception - the exception to supply to the warningCallback function.oldResource - the old resource that is being compared to the new draft.newResourceDraft - the new resource draft that is being compared to the old resource.public void applyErrorCallback(@Nonnull
SyncException exception,
@Nullable
U oldResource,
@Nullable
V newResourceDraft,
@Nullable
java.util.List<io.sphere.sdk.commands.UpdateAction<A>> updateActions)
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.exception - Throwable instance to supply as first param to the errorCallback function.oldResource - the old resource that is being compared to the new draft.newResourceDraft - the new resource draft that is being compared to the old resource.updateActions - the list of update actions.public void applyErrorCallback(@Nonnull
SyncException syncException)
syncException - Throwable instance to supply as first param to the errorCallback function.applyErrorCallback(SyncException exception, Object oldResource, Object newResource, List
updateActions)public void applyErrorCallback(@Nonnull
java.lang.String errorMessage)
errorMessage - the error message to supply as part of first param to the errorCallback function.applyErrorCallback(SyncException exception, Object oldResource, Object newResource, List
updateActions)public int getBatchSize()
This batch size is set to 30 by default.
public long getCacheSize()
This cache size is set to 100.000 by default.
@Nullable public TriFunction<java.util.List<io.sphere.sdk.commands.UpdateAction<A>>,V,U,java.util.List<io.sphere.sdk.commands.UpdateAction<A>>> 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<A>> applyBeforeUpdateCallback(@Nonnull java.util.List<io.sphere.sdk.commands.UpdateAction<A>> 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 or updateActions is empty, this method does nothing to the supplied list of updateActions
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 is null or updateActions is empty, the
supplied list of updateActions is returned as is. If the return of the callback is
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 is null,
the supplied resource draft is returned as is, wrapped in an optional.