Class PlainEnumValueUpdateActionUtils


  • public final class PlainEnumValueUpdateActionUtils
    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> buildEnumValuesUpdateActions​(java.lang.String attributeDefinitionName, java.util.List<com.commercetools.api.models.product_type.AttributePlainEnumValue> oldEnumValues, java.util.List<com.commercetools.api.models.product_type.AttributePlainEnumValue> newEnumValues)
      Compares a list of old AttributePlainEnumValues with a list of new AttributePlainEnumValues for a given attribute definition and builds required update actions (e.g addEnumValue, removeEnumValue, changeEnumValueOrder) and 1-1 update actions on enum values (e.g.
      static java.util.List<com.commercetools.api.models.product_type.ProductTypeUpdateAction> buildEnumValueUpdateActions​(java.lang.String attributeDefinitionName, com.commercetools.api.models.product_type.AttributePlainEnumValue oldEnumValue, com.commercetools.api.models.product_type.AttributePlainEnumValue newEnumValue)
      Compares all the fields of an old AttributePlainEnumValue and a new AttributePlainEnumValue and returns a list of ProductTypeUpdateAction as a result.
      • Methods inherited from class java.lang.Object

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

      • buildEnumValuesUpdateActions

        @Nonnull
        public static java.util.List<com.commercetools.api.models.product_type.ProductTypeUpdateAction> buildEnumValuesUpdateActions​(@Nonnull
                                                                                                                                     java.lang.String attributeDefinitionName,
                                                                                                                                     @Nonnull
                                                                                                                                     java.util.List<com.commercetools.api.models.product_type.AttributePlainEnumValue> oldEnumValues,
                                                                                                                                     @Nullable
                                                                                                                                     java.util.List<com.commercetools.api.models.product_type.AttributePlainEnumValue> newEnumValues)
        Compares a list of old AttributePlainEnumValues with a list of new AttributePlainEnumValues for a given attribute definition and builds required update actions (e.g addEnumValue, removeEnumValue, changeEnumValueOrder) and 1-1 update actions on enum values (e.g. changeEnumValueLabel) for the required resource. If both the AttributePlainEnumValue's are identical, then no update action is needed and hence an empty List is returned.

        If the list of new AttributePlainEnumValues is null, then remove actions are built for every existing plain enum value in the oldEnumValues list.

        Parameters:
        attributeDefinitionName - the attribute name whose plain enum values are going to be synced.
        oldEnumValues - the old list of plain enum values.
        newEnumValues - the new list of plain enum values.
        Returns:
        a list of plain enum values update actions if the list of plain enum values is not identical. Otherwise, if the plain enum values are identical, an empty list is returned.
        Throws:
        DuplicateKeyException - in case there are localized enum values with duplicate keys.
      • buildEnumValueUpdateActions

        @Nonnull
        public static java.util.List<com.commercetools.api.models.product_type.ProductTypeUpdateAction> buildEnumValueUpdateActions​(@Nonnull
                                                                                                                                    java.lang.String attributeDefinitionName,
                                                                                                                                    @Nonnull
                                                                                                                                    com.commercetools.api.models.product_type.AttributePlainEnumValue oldEnumValue,
                                                                                                                                    @Nonnull
                                                                                                                                    com.commercetools.api.models.product_type.AttributePlainEnumValue newEnumValue)
        Compares all the fields of an old AttributePlainEnumValue and a new AttributePlainEnumValue and returns a list of ProductTypeUpdateAction as a result. If both AttributePlainEnumValue have identical fields, then no update action is needed and hence an empty List is returned.
        Parameters:
        attributeDefinitionName - the attribute definition name whose plain enum values belong to.
        oldEnumValue - the enum value which should be updated.
        newEnumValue - the enum value where we get the new fields.
        Returns:
        A list with the update actions or an empty list if the enum values are identical.