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<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.products.Product>> buildActions​(io.sphere.sdk.products.ProductDraft newProduct, java.lang.Integer variantId, io.sphere.sdk.products.Price oldPrice, io.sphere.sdk.products.PriceDraft newPrice, ProductSyncOptions syncOptions)
      Compares all the fields of a Price and a PriceDraft and returns a list of UpdateAction<Product> as a result.
      static java.util.Optional<io.sphere.sdk.products.commands.updateactions.ChangePrice> buildChangePriceUpdateAction​(io.sphere.sdk.products.Price oldPrice, io.sphere.sdk.products.PriceDraft newPrice, ProductSyncOptions syncOptions)
      Builds a ChangePrice 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<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.products.Product>> buildCustomUpdateActions​(io.sphere.sdk.products.ProductDraft newProduct, java.lang.Integer variantId, io.sphere.sdk.products.Price oldPrice, io.sphere.sdk.products.PriceDraft newPrice, ProductSyncOptions syncOptions)
      Compares the custom fields and custom types of a Price and a PriceDraft and returns a list of UpdateAction<Product> as a result.
      • 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<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.products.Product>> buildActions​(@Nonnull
                                                                                                                       io.sphere.sdk.products.ProductDraft newProduct,
                                                                                                                       @Nonnull
                                                                                                                       java.lang.Integer variantId,
                                                                                                                       @Nonnull
                                                                                                                       io.sphere.sdk.products.Price oldPrice,
                                                                                                                       @Nonnull
                                                                                                                       io.sphere.sdk.products.PriceDraft newPrice,
                                                                                                                       @Nonnull
                                                                                                                       ProductSyncOptions syncOptions)
        Compares all the fields of a Price and a PriceDraft and returns a list of UpdateAction<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<io.sphere.sdk.products.commands.updateactions.ChangePrice> buildChangePriceUpdateAction​(@Nonnull
                                                                                                                                 io.sphere.sdk.products.Price oldPrice,
                                                                                                                                 @Nonnull
                                                                                                                                 io.sphere.sdk.products.PriceDraft newPrice,
                                                                                                                                 @Nonnull
                                                                                                                                 ProductSyncOptions syncOptions)
        Builds a ChangePrice 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 ChangePrice 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<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.products.Product>> buildCustomUpdateActions​(@Nonnull
                                                                                                                                   io.sphere.sdk.products.ProductDraft newProduct,
                                                                                                                                   @Nonnull
                                                                                                                                   java.lang.Integer variantId,
                                                                                                                                   @Nonnull
                                                                                                                                   io.sphere.sdk.products.Price oldPrice,
                                                                                                                                   @Nonnull
                                                                                                                                   io.sphere.sdk.products.PriceDraft newPrice,
                                                                                                                                   @Nonnull
                                                                                                                                   ProductSyncOptions syncOptions)
        Compares the custom fields and custom types of a Price and a PriceDraft and returns a list of UpdateAction<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.