Class TypeUpdateActionUtils


  • public final class TypeUpdateActionUtils
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.Optional<com.commercetools.api.models.type.TypeUpdateAction> buildChangeNameUpdateAction​(com.commercetools.api.models.type.Type oldType, com.commercetools.api.models.type.TypeDraft newType)
      Compares the LocalizedString name values of a Type and a TypeDraft and returns an Optional of update action, which would contain the TypeChangeNameAction if values are different.
      static java.util.List<com.commercetools.api.models.type.TypeUpdateAction> buildFieldDefinitionsUpdateActions​(com.commercetools.api.models.type.Type oldType, com.commercetools.api.models.type.TypeDraft newType, TypeSyncOptions syncOptions)
      Compares the field definitions of a Type and a TypeDraft and returns a list of TypeUpdateAction as a result if the values are different.
      static java.util.Optional<com.commercetools.api.models.type.TypeUpdateAction> buildSetDescriptionUpdateAction​(com.commercetools.api.models.type.Type oldType, com.commercetools.api.models.type.TypeDraft newType)
      Compares the LocalizedString descriptions of a Type and a TypeDraft and returns an TypeSetDescriptionAction as a result in an Optional of update action if values are different.
      • Methods inherited from class java.lang.Object

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

      • buildChangeNameUpdateAction

        @Nonnull
        public static java.util.Optional<com.commercetools.api.models.type.TypeUpdateAction> buildChangeNameUpdateAction​(@Nonnull
                                                                                                                         com.commercetools.api.models.type.Type oldType,
                                                                                                                         @Nonnull
                                                                                                                         com.commercetools.api.models.type.TypeDraft newType)
        Compares the LocalizedString name values of a Type and a TypeDraft and returns an Optional of update action, which would contain the TypeChangeNameAction if values are different.
        Parameters:
        oldType - the type that should be updated.
        newType - the type draft which contains the new name.
        Returns:
        optional containing update action or empty optional if names are identical.
      • buildSetDescriptionUpdateAction

        @Nonnull
        public static java.util.Optional<com.commercetools.api.models.type.TypeUpdateAction> buildSetDescriptionUpdateAction​(@Nonnull
                                                                                                                             com.commercetools.api.models.type.Type oldType,
                                                                                                                             @Nonnull
                                                                                                                             com.commercetools.api.models.type.TypeDraft newType)
        Compares the LocalizedString descriptions of a Type and a TypeDraft and returns an TypeSetDescriptionAction as a result in an Optional of update action if values are different.
        Parameters:
        oldType - the type which should be updated.
        newType - the type draft where we get the new description.
        Returns:
        A filled optional with the update action or an empty optional if the descriptions are identical.
      • buildFieldDefinitionsUpdateActions

        @Nonnull
        public static java.util.List<com.commercetools.api.models.type.TypeUpdateAction> buildFieldDefinitionsUpdateActions​(@Nonnull
                                                                                                                            com.commercetools.api.models.type.Type oldType,
                                                                                                                            @Nonnull
                                                                                                                            com.commercetools.api.models.type.TypeDraft newType,
                                                                                                                            @Nonnull
                                                                                                                            TypeSyncOptions syncOptions)
        Compares the field definitions of a Type and a TypeDraft and returns a list of TypeUpdateAction as a result if the values are different. In case, the new type draft has a list of field definitions in which a duplicate name exists, the error callback is triggered and an empty list is returned.

        Note: Currently commercetools API doesn't support the following:

        • removing the EnumValue/LocalizedEnumValue of a FieldDefinition
        Parameters:
        oldType - the type which should be updated.
        newType - the 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 field definitions are identical.