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<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.types.Type>> buildChangeNameUpdateAction​(io.sphere.sdk.types.Type oldType, io.sphere.sdk.types.TypeDraft newType)
      Compares the LocalizedString name values of a Type and a TypeDraft and returns an Optional of update action, which would contain the "changeName" UpdateAction if values are different.
      static java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.types.Type>> buildFieldDefinitionsUpdateActions​(io.sphere.sdk.types.Type oldType, io.sphere.sdk.types.TypeDraft newType, TypeSyncOptions syncOptions)
      Compares the field definitions of a Type and a TypeDraft and returns a list of UpdateAction<Type> as a result if the values are different.
      static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.types.Type>> buildSetDescriptionUpdateAction​(io.sphere.sdk.types.Type oldType, io.sphere.sdk.types.TypeDraft newType)
      Compares the LocalizedString descriptions of a Type and a TypeDraft and returns an UpdateAction<Type> 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<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.types.Type>> buildChangeNameUpdateAction​(@Nonnull
                                                                                                                                    io.sphere.sdk.types.Type oldType,
                                                                                                                                    @Nonnull
                                                                                                                                    io.sphere.sdk.types.TypeDraft newType)
        Compares the LocalizedString name values of a Type and a TypeDraft and returns an Optional of update action, which would contain the "changeName" UpdateAction 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<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.types.Type>> buildSetDescriptionUpdateAction​(@Nonnull
                                                                                                                                        io.sphere.sdk.types.Type oldType,
                                                                                                                                        @Nonnull
                                                                                                                                        io.sphere.sdk.types.TypeDraft newType)
        Compares the LocalizedString descriptions of a Type and a TypeDraft and returns an UpdateAction<Type> 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<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.types.Type>> buildFieldDefinitionsUpdateActions​(@Nonnull
                                                                                                                                       io.sphere.sdk.types.Type oldType,
                                                                                                                                       @Nonnull
                                                                                                                                       io.sphere.sdk.types.TypeDraft newType,
                                                                                                                                       @Nonnull
                                                                                                                                       TypeSyncOptions syncOptions)
        Compares the field definitions of a Type and a TypeDraft and returns a list of UpdateAction<Type> 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 this util doesn't support the following:

        • updating the inputHint of a FieldDefinition
        • removing the EnumValue/LocalizedEnumValue of a FieldDefinition
        • updating the label of a EnumValue/LocalizedEnumValue of a FieldDefinition
        TODO: Check GITHUB ISSUE#339 for missing FieldDefinition update actions.
        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.