Class ProductVariantPriceUpdateActionUtils


  • public final class ProductVariantPriceUpdateActionUtils
    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.ProductUpdateAction> buildActions​(com.commercetools.api.models.product.ProductDraft newProduct, java.lang.Long variantId, com.commercetools.api.models.common.Price oldPrice, com.commercetools.api.models.common.PriceDraft newPrice, ProductSyncOptions syncOptions)
      Compares all the fields of a Price and a PriceDraft and returns a list of
      static java.util.Optional<com.commercetools.api.models.product.ProductUpdateAction> buildChangePriceUpdateAction​(com.commercetools.api.models.common.Price oldPrice, com.commercetools.api.models.common.PriceDraft newPrice, ProductSyncOptions syncOptions)
      Builds a ProductChangePriceAction action based on the comparison of the following fields of the supplied Price and PriceDraft: Price.getValue() and PriceDraft.getValue() Price.getTiers() and PriceDraft.getTiers()
      static java.util.List<com.commercetools.api.models.product.ProductUpdateAction> buildCustomUpdateActions​(com.commercetools.api.models.product.ProductDraft newProduct, java.lang.Long variantId, com.commercetools.api.models.common.Price oldPrice, com.commercetools.api.models.common.PriceDraft newPrice, ProductSyncOptions syncOptions)
      Compares the custom fields and custom types of a Price and a PriceDraft and
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • buildActions

        @Nonnull
        public static java.util.List<com.commercetools.api.models.product.ProductUpdateAction> buildActions​(@Nonnull
                                                                                                            com.commercetools.api.models.product.ProductDraft newProduct,
                                                                                                            @Nonnull
                                                                                                            java.lang.Long variantId,
                                                                                                            @Nonnull
                                                                                                            com.commercetools.api.models.common.Price oldPrice,
                                                                                                            @Nonnull
                                                                                                            com.commercetools.api.models.common.PriceDraft newPrice,
                                                                                                            @Nonnull
                                                                                                            ProductSyncOptions syncOptions)
        Compares all the fields of a Price and a PriceDraft and returns a list of

        ProductUpdateAction<Product> as a result. If both the Price and the PriceDraft have identical fields, then no update action is needed and hence an empty List is returned.

        Parameters:
        newProduct - new product draft, which provides the prices to update.
        variantId - the variantId needed for building the update action.
        oldPrice - the price which should be updated.
        newPrice - the price 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 price fields are identical.
      • buildChangePriceUpdateAction

        @Nonnull
        public static java.util.Optional<com.commercetools.api.models.product.ProductUpdateAction> buildChangePriceUpdateAction​(@Nonnull
                                                                                                                                com.commercetools.api.models.common.Price oldPrice,
                                                                                                                                @Nonnull
                                                                                                                                com.commercetools.api.models.common.PriceDraft newPrice,
                                                                                                                                @Nonnull
                                                                                                                                ProductSyncOptions syncOptions)
        Builds a ProductChangePriceAction action based on the comparison of the following fields of the supplied Price and PriceDraft:
        • Price.getValue() and PriceDraft.getValue()
        • Price.getTiers() and PriceDraft.getTiers()

        If any of the aforementioned fields are different a ProductChangePriceAction update action will be returned in an Optional, otherwise if both are identical in the Price and the PriceDraft, then no update action is needed and hence an empty Optional is returned.

        Parameters:
        oldPrice - the price which should be updated.
        newPrice - the price draft where we get the new name.
        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 filled optional with the update action or an empty optional if the names are identical.
      • buildCustomUpdateActions

        @Nonnull
        public static java.util.List<com.commercetools.api.models.product.ProductUpdateAction> buildCustomUpdateActions​(@Nonnull
                                                                                                                        com.commercetools.api.models.product.ProductDraft newProduct,
                                                                                                                        @Nonnull
                                                                                                                        java.lang.Long variantId,
                                                                                                                        @Nonnull
                                                                                                                        com.commercetools.api.models.common.Price oldPrice,
                                                                                                                        @Nonnull
                                                                                                                        com.commercetools.api.models.common.PriceDraft newPrice,
                                                                                                                        @Nonnull
                                                                                                                        ProductSyncOptions syncOptions)
        Compares the custom fields and custom types of a Price and a PriceDraft and

        returns a list of ProductUpdateAction<Product> as a result. If both the Price and the PriceDraft have identical custom fields and types, then no update action is needed and hence an empty List is returned.

        Parameters:
        newProduct - new product draft, which provides the prices to update.
        variantId - the variantId needed for building the update action.
        oldPrice - the price which should be updated.
        newPrice - the price 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.