Class UpdateActionsSortUtils


  • public final class UpdateActionsSortUtils
    extends java.lang.Object
    This class is only meant for the internal use of the commercetools-sync-java library.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.List<com.commercetools.api.models.product.ProductUpdateAction> sortPriceActions​(java.util.List<com.commercetools.api.models.product.ProductUpdateAction> updateActions)
      Given a list of update actions, this method returns a copy of the supplied list but sorted with the following precedence: ProductRemovePriceAction ProductChangePriceAction or ProductSetProductPriceCustomTypeAction or ProductSetProductPriceCustomFieldAction ProductAddPriceAction
      • Methods inherited from class java.lang.Object

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

      • sortPriceActions

        @Nonnull
        public static java.util.List<com.commercetools.api.models.product.ProductUpdateAction> sortPriceActions​(@Nonnull
                                                                                                                java.util.List<com.commercetools.api.models.product.ProductUpdateAction> updateActions)
        Given a list of update actions, this method returns a copy of the supplied list but sorted with the following precedence:
        1. ProductRemovePriceAction
        2. ProductChangePriceAction or ProductSetProductPriceCustomTypeAction or ProductSetProductPriceCustomFieldAction
        3. ProductAddPriceAction

        This is to ensure that there are no conflicts when adding a new price that might have a duplicate value for a unique field, which could already be changed or removed.

        Parameters:
        updateActions - list of update actions to sort.
        Returns:
        a new sorted list of update actions (remove, change, add).