Class ProductTypeUpdateActionUtils
- java.lang.Object
-
- com.commercetools.sync.producttypes.utils.ProductTypeUpdateActionUtils
-
public final class ProductTypeUpdateActionUtils extends java.lang.Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.List<com.commercetools.api.models.product_type.ProductTypeUpdateAction>
buildAttributesUpdateActions(com.commercetools.api.models.product_type.ProductType oldProductType, com.commercetools.api.models.product_type.ProductTypeDraft newProductType, ProductTypeSyncOptions syncOptions)
Compares the attributes of aProductType
and aProductTypeDraft
and returns a list ofProductTypeUpdateAction
as a result.static java.util.Optional<com.commercetools.api.models.product_type.ProductTypeUpdateAction>
buildChangeDescriptionAction(com.commercetools.api.models.product_type.ProductType oldProductType, com.commercetools.api.models.product_type.ProductTypeDraft newProductType)
Compares thedescription
values of aProductType
and aProductTypeDraft
and returns anOptional
of update action, which would contain theProductTypeChangeDescriptionAction
.static java.util.Optional<com.commercetools.api.models.product_type.ProductTypeUpdateAction>
buildChangeNameAction(com.commercetools.api.models.product_type.ProductType oldProductType, com.commercetools.api.models.product_type.ProductTypeDraft newProductType)
Compares thename
values of aProductType
and aProductTypeDraft
and returns anOptional
of update action, which would contain the"changeName"
ProductTypeChangeNameAction
.
-
-
-
Method Detail
-
buildChangeNameAction
@Nonnull public static java.util.Optional<com.commercetools.api.models.product_type.ProductTypeUpdateAction> buildChangeNameAction(@Nonnull com.commercetools.api.models.product_type.ProductType oldProductType, @Nonnull com.commercetools.api.models.product_type.ProductTypeDraft newProductType)
Compares thename
values of aProductType
and aProductTypeDraft
and returns anOptional
of update action, which would contain the"changeName"
ProductTypeChangeNameAction
. If bothProductType
andProductTypeDraft
have the samename
values, then no update action is needed and empty optional will be returned.- Parameters:
oldProductType
- the product type that should be updated.newProductType
- the product type draft which contains the new name.- Returns:
- optional containing update action or empty optional if names are identical.
-
buildChangeDescriptionAction
@Nonnull public static java.util.Optional<com.commercetools.api.models.product_type.ProductTypeUpdateAction> buildChangeDescriptionAction(@Nonnull com.commercetools.api.models.product_type.ProductType oldProductType, @Nonnull com.commercetools.api.models.product_type.ProductTypeDraft newProductType)
Compares thedescription
values of aProductType
and aProductTypeDraft
and returns anOptional
of update action, which would contain theProductTypeChangeDescriptionAction
. If bothProductType
andProductTypeDraft
have the samedescription
values, then no update action is needed and empty optional will be returned.- Parameters:
oldProductType
- the product type that should be updated.newProductType
- the product type draft which contains the new description.- Returns:
- optional containing update action or empty optional if descriptions are identical.
-
buildAttributesUpdateActions
@Nonnull public static java.util.List<com.commercetools.api.models.product_type.ProductTypeUpdateAction> buildAttributesUpdateActions(@Nonnull com.commercetools.api.models.product_type.ProductType oldProductType, @Nonnull com.commercetools.api.models.product_type.ProductTypeDraft newProductType, @Nonnull ProductTypeSyncOptions syncOptions)
Compares the attributes of aProductType
and aProductTypeDraft
and returns a list ofProductTypeUpdateAction
as a result. If both theProductType
and theProductTypeDraft
have identical attributes, then no update action is needed and hence an emptyList
is returned. In case, the new product type draft has a list of attributes in which a duplicate name exists, the error callback is triggered and an empty list is returned.- Parameters:
oldProductType
- the product type which should be updated.newProductType
- the product type draft where we get the key.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 attributes are identical.
-
-