public final class SyncUtils
extends java.lang.Object
| Constructor and Description |
|---|
SyncUtils() |
| Modifier and Type | Method and Description |
|---|---|
static <T> java.util.List<java.util.List<T>> |
batchDrafts(java.util.List<T> drafts,
int batchSize)
Given a list of resource (e.g.
|
static <T extends io.sphere.sdk.types.Custom> |
replaceCustomTypeIdWithKeys(T resource)
Given a resource of type
T that extends Custom (i.e. |
static <T> io.sphere.sdk.models.Reference<T> |
replaceReferenceIdWithKey(io.sphere.sdk.models.Reference<T> reference,
java.util.function.Supplier<io.sphere.sdk.models.Reference<T>> keyInReferenceSupplier)
Given a reference to a resource of type
T, this method
checks if the reference is expanded. |
public static <T> java.util.List<java.util.List<T>> batchDrafts(@Nonnull
java.util.List<T> drafts,
int batchSize)
batchSize, this method separates
the drafts into batches with the batchSize. Each batch is represented by a
List of resources and all the batches are grouped and represented by an
List<List> of resources, which is returned by the method.T - the type of the draft resources.drafts - the list of drafts to split into batches.batchSize - the size of each batch.@Nullable
public static <T extends io.sphere.sdk.types.Custom> io.sphere.sdk.types.CustomFieldsDraft replaceCustomTypeIdWithKeys(@Nonnull
T resource)
T that extends Custom (i.e. it has CustomFields, this method
checks if the custom fields are existing (not null) and they are reference expanded. If they are then
it returns a CustomFieldsDraft instance with the custom type key in place of the id of the reference.
Otherwise, if its not reference expanded it returns a CustomFieldsDraft with the id not replaced. If the
resource has no or null Custom, then it returns null.T - the type of the resource.resource - the resource to replace its custom type id, if possible.CustomFieldsDraft instance with the custom type key in place of the id, if the
custom type reference was existing and reference expanded on the resource. Otherwise, if its not
reference expanded it returns a CustomFieldsDraft with the id not replaced with key. If the
resource has no or null Custom, then it returns null.@Nullable
public static <T> io.sphere.sdk.models.Reference<T> replaceReferenceIdWithKey(@Nullable
io.sphere.sdk.models.Reference<T> reference,
@Nonnull
java.util.function.Supplier<io.sphere.sdk.models.Reference<T>> keyInReferenceSupplier)
T, this method
checks if the reference is expanded. If it is, then it executes the keyInReferenceSupplier and returns
it's result. Otherwise, it returns the supplied reference as is. Since, the reference could be null, this
method could also return null if the reference was not expanded.T - the type of the resource.reference - the reference of the resource to check if it's expanded.keyInReferenceSupplier - the supplier to execute and return its result if the reference was
expanded.keyInReferenceSupplier if the reference was expanded.
Otherwise, it returns the supplied reference as is.