Class CategoryAssetUpdateActionUtils
- java.lang.Object
-
- com.commercetools.sync.categories.utils.CategoryAssetUpdateActionUtils
-
public final class CategoryAssetUpdateActionUtils extends java.lang.Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <D> java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.categories.Category>>
buildActions(io.sphere.sdk.models.Resource oldResource, D newResource, io.sphere.sdk.models.Asset oldAsset, io.sphere.sdk.models.AssetDraft newAsset, CategorySyncOptions syncOptions)
Compares all the fields of anAsset
and anAssetDraft
and returns a list ofUpdateAction
<Category
> as a result.static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.categories.Category>>
buildChangeAssetNameUpdateAction(io.sphere.sdk.models.Asset oldAsset, io.sphere.sdk.models.AssetDraft newAsset)
Compares theLocalizedString
names of anAsset
and anAssetDraft
and returns anUpdateAction
<Category
> as a result in anOptional
.static <D> java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.categories.Category>>
buildCustomUpdateActions(io.sphere.sdk.models.Resource oldCategory, D newCategory, io.sphere.sdk.models.Asset oldAsset, io.sphere.sdk.models.AssetDraft newAsset, CategorySyncOptions syncOptions)
Compares the custom fields and custom types of anAsset
and anAssetDraft
and returns a list ofUpdateAction
<Category
> as a result.static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.categories.Category>>
buildSetAssetDescriptionUpdateAction(io.sphere.sdk.models.Asset oldAsset, io.sphere.sdk.models.AssetDraft newAsset)
Compares theLocalizedString
descriptions of anAsset
and anAssetDraft
and returns anUpdateAction
<Category
> as a result in anOptional
.static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.categories.Category>>
buildSetAssetSourcesUpdateAction(io.sphere.sdk.models.Asset oldAsset, io.sphere.sdk.models.AssetDraft newAsset)
Compares the sources of anAsset
and anAssetDraft
and returns anUpdateAction
<Category
> as a result in anOptional
.static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.categories.Category>>
buildSetAssetTagsUpdateAction(io.sphere.sdk.models.Asset oldAsset, io.sphere.sdk.models.AssetDraft newAsset)
Compares the tags of anAsset
and anAssetDraft
and returns anUpdateAction
<Category
> as a result in anOptional
.
-
-
-
Method Detail
-
buildActions
@Nonnull public static <D> java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.categories.Category>> buildActions(@Nonnull io.sphere.sdk.models.Resource oldResource, @Nonnull D newResource, @Nonnull io.sphere.sdk.models.Asset oldAsset, @Nonnull io.sphere.sdk.models.AssetDraft newAsset, @Nonnull CategorySyncOptions syncOptions)
Compares all the fields of anAsset
and anAssetDraft
and returns a list ofUpdateAction
<Category
> as a result. If both theAsset
and theAssetDraft
have identical fields, then no update action is needed and hence an emptyList
is returned.- Type Parameters:
D
- Type of the mainresource draft- Parameters:
oldResource
- mainresource, whose asset should be updated.newResource
- new mainresource draft, which contains the asset to update.oldAsset
- the asset which should be updated.newAsset
- the asset draft where we get the new fields.syncOptions
- responsible for supplying the sync options to the sync utility method. It is used for triggering the error callback within the utility, in case of errors.- Returns:
- A list with the update actions or an empty list if the asset fields are identical.
-
buildChangeAssetNameUpdateAction
@Nonnull public static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.categories.Category>> buildChangeAssetNameUpdateAction(@Nonnull io.sphere.sdk.models.Asset oldAsset, @Nonnull io.sphere.sdk.models.AssetDraft newAsset)
Compares theLocalizedString
names of anAsset
and anAssetDraft
and returns anUpdateAction
<Category
> as a result in anOptional
. If both theAsset
and theAssetDraft
have the same name, then no update action is needed and hence an emptyOptional
is returned.- Parameters:
oldAsset
- the asset which should be updated.newAsset
- the asset draft where we get the new name.- Returns:
- A filled optional with the update action or an empty optional if the names are identical.
-
buildSetAssetDescriptionUpdateAction
@Nonnull public static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.categories.Category>> buildSetAssetDescriptionUpdateAction(@Nonnull io.sphere.sdk.models.Asset oldAsset, @Nonnull io.sphere.sdk.models.AssetDraft newAsset)
Compares theLocalizedString
descriptions of anAsset
and anAssetDraft
and returns anUpdateAction
<Category
> as a result in anOptional
. If both theAsset
and theAssetDraft
have the same description, then no update action is needed and hence an emptyOptional
is returned.- Parameters:
oldAsset
- the asset which should be updated.newAsset
- the asset draft where we get the new description.- Returns:
- A filled optional with the update action or an empty optional if the descriptions are identical.
-
buildSetAssetTagsUpdateAction
@Nonnull public static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.categories.Category>> buildSetAssetTagsUpdateAction(@Nonnull io.sphere.sdk.models.Asset oldAsset, @Nonnull io.sphere.sdk.models.AssetDraft newAsset)
Compares the tags of anAsset
and anAssetDraft
and returns anUpdateAction
<Category
> as a result in anOptional
. If both theAsset
and theAssetDraft
have the same tags, then no update action is needed and hence an emptyOptional
is returned.- Parameters:
oldAsset
- the asset which should be updated.newAsset
- the asset draft where we get the new tags.- Returns:
- A filled optional with the update action or an empty optional if the tags are identical.
-
buildSetAssetSourcesUpdateAction
@Nonnull public static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.categories.Category>> buildSetAssetSourcesUpdateAction(@Nonnull io.sphere.sdk.models.Asset oldAsset, @Nonnull io.sphere.sdk.models.AssetDraft newAsset)
Compares the sources of anAsset
and anAssetDraft
and returns anUpdateAction
<Category
> as a result in anOptional
. If both theAsset
and theAssetDraft
have the same sources, then no update action is needed and hence an emptyOptional
is returned.- Parameters:
oldAsset
- the asset which should be updated.newAsset
- the asset draft where we get the new sources.- Returns:
- A filled optional with the update action or an empty optional if the sources are identical.
-
buildCustomUpdateActions
@Nonnull public static <D> java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.categories.Category>> buildCustomUpdateActions(@Nonnull io.sphere.sdk.models.Resource oldCategory, @Nonnull D newCategory, @Nonnull io.sphere.sdk.models.Asset oldAsset, @Nonnull io.sphere.sdk.models.AssetDraft newAsset, @Nonnull CategorySyncOptions syncOptions)
Compares the custom fields and custom types of anAsset
and anAssetDraft
and returns a list ofUpdateAction
<Category
> as a result. If both theAsset
and theAssetDraft
have identical custom fields and types, then no update action is needed and hence an emptyList
is returned.- Type Parameters:
D
- Type of the mainresource draft- Parameters:
oldCategory
- category in a target project, whose asset should be updated.newCategory
- category in a source project, which contains the updated asset.oldAsset
- the asset which should be updated.newAsset
- the asset draft where we get the new custom fields and types.syncOptions
- responsible for supplying the sync options to the sync utility method. It is used for triggering the error callback within the utility, in case of errors.- Returns:
- A list with the custom field/type update actions or an empty list if the custom fields/types are identical.
-
-