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 aProductTypeand aProductTypeDraftand returns a list ofProductTypeUpdateActionas 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 thedescriptionvalues of aProductTypeand aProductTypeDraftand returns anOptionalof 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 thenamevalues of aProductTypeand aProductTypeDraftand returns anOptionalof 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 thenamevalues of aProductTypeand aProductTypeDraftand returns anOptionalof update action, which would contain the"changeName"ProductTypeChangeNameAction. If bothProductTypeandProductTypeDrafthave the samenamevalues, 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 thedescriptionvalues of aProductTypeand aProductTypeDraftand returns anOptionalof update action, which would contain theProductTypeChangeDescriptionAction. If bothProductTypeandProductTypeDrafthave the samedescriptionvalues, 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 aProductTypeand aProductTypeDraftand returns a list ofProductTypeUpdateActionas a result. If both theProductTypeand theProductTypeDrafthave identical attributes, then no update action is needed and hence an emptyListis 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.
-
-