public final class CustomUpdateActionUtils
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static <D,T extends io.sphere.sdk.types.Custom,S extends io.sphere.sdk.types.CustomDraft,U extends io.sphere.sdk.models.ResourceView> |
buildCustomUpdateActions(D newMainResourceDraft,
T oldResource,
S newResourceDraft,
GenericCustomActionBuilder<U> customActionBuilder,
java.lang.Integer variantId,
java.util.function.Function<T,java.lang.String> resourceIdGetter,
java.util.function.Function<T,java.lang.String> resourceTypeIdGetter,
java.util.function.Function<T,java.lang.String> updateIdGetter,
BaseSyncOptions syncOptions)
Compares the
CustomFields of an old resource T (for example Category ,
Product , etc..), to the CustomFieldsDraft , of a new
resource draft S (for example CategoryDraft , ProductVariantDraft , etc..), and returns a List <UpdateAction > as a result. |
static <T extends io.sphere.sdk.types.Custom & io.sphere.sdk.models.Resource<T>,S extends io.sphere.sdk.types.CustomDraft> |
buildPrimaryResourceCustomUpdateActions(T oldResource,
S newResource,
GenericCustomActionBuilder<T> customActionBuilder,
BaseSyncOptions syncOptions)
This method is a syntactic sugar for the method
buildCustomUpdateActions(Custom,
CustomDraft, GenericCustomActionBuilder, Integer, Function, Function, Function,
BaseSyncOptions) but this one is only for primary resources (i.e resources which have their
own endpoints for example channels, categories, inventory entries. |
@Nonnull public static <T extends io.sphere.sdk.types.Custom & io.sphere.sdk.models.Resource<T>,S extends io.sphere.sdk.types.CustomDraft> java.util.List<io.sphere.sdk.commands.UpdateAction<T>> buildPrimaryResourceCustomUpdateActions(@Nonnull T oldResource, @Nonnull S newResource, @Nonnull GenericCustomActionBuilder<T> customActionBuilder, @Nonnull BaseSyncOptions syncOptions)
buildCustomUpdateActions(Custom,
CustomDraft, GenericCustomActionBuilder, Integer, Function, Function, Function,
BaseSyncOptions)
but this one is only for primary resources (i.e resources which have their
own endpoints for example channels, categories, inventory entries. For more details of the
inner logic and different scenarios, check the Javadoc of the other method.T
- the type of the old Resource
which has the custom fields.S
- the type of the new resource CustomDraft
.oldResource
- the resource which should be updated.newResource
- the resource draft where we get the new custom fields.customActionBuilder
- the builder instance responsible for building the custom update
actions.syncOptions
- responsible for supplying the sync options to the sync utility method.)
@Nonnull public static <D,T extends io.sphere.sdk.types.Custom,S extends io.sphere.sdk.types.CustomDraft,U extends io.sphere.sdk.models.ResourceView> java.util.List<io.sphere.sdk.commands.UpdateAction<U>> buildCustomUpdateActions(@Nullable D newMainResourceDraft, @Nonnull T oldResource, @Nonnull S newResourceDraft, @Nonnull GenericCustomActionBuilder<U> customActionBuilder, @Nullable java.lang.Integer variantId, @Nonnull java.util.function.Function<T,java.lang.String> resourceIdGetter, @Nonnull java.util.function.Function<T,java.lang.String> resourceTypeIdGetter, @Nonnull java.util.function.Function<T,java.lang.String> updateIdGetter, @Nonnull BaseSyncOptions syncOptions)
CustomFields
of an old resource T
(for example Category
,
Product
, etc..), to the CustomFieldsDraft
, of a new
resource draft S
(for example CategoryDraft
, ProductVariantDraft
, etc..), and returns a List
<UpdateAction
> as a result. If no update action is needed, for example in the case where
both the CustomFields
and the CustomFieldsDraft
are null, an empty List
<UpdateAction
> is returned. A BaseSyncOptions
instance is injected
into the method which is responsible for supplying the sync options to the sync utility method.
For example, custom error callbacks for errors. The TypeService
is injected also for
fetching the key of the old resource type from it's cache (see buildNonNullCustomFieldsUpdateActions(CustomFields, CustomFieldsDraft,
Custom, GenericCustomActionBuilder, Integer, Function, Function, Function, BaseSyncOptions)
).
An update action will be added to the result list in the following cases:-
buildSetCustomFieldsUpdateActions(Map, Map, Custom,
GenericCustomActionBuilder, Integer, Function)
)})
An update action will not be added to the result list in the following cases:-
D
- the type of the new Resource
which is the super Resource
of the
Resource to update.T
- the type of the old Resource
which has the custom fields.S
- the type of the new resource CustomDraft
.U
- the type of the resource in which the update actions will be applied on.newMainResourceDraft
- the main resource of the resource draft where we get the new custom
fields.oldResource
- the resource which should be updated.newResourceDraft
- the resource draft where we get the new custom fields.customActionBuilder
- the builder instance responsible for building the custom update
actions.variantId
- optional field representing the variant id in case the oldResource is an
asset.resourceIdGetter
- a function used to get the id of the resource being updated.resourceTypeIdGetter
- a function used to get the Type id of the resource being updated.updateIdGetter
- a function used to get the id/key needed for updating the resource that
has the custom fields.syncOptions
- responsible for supplying the sync options to the sync utility method.