Class TypeUpdateActionUtils
- java.lang.Object
-
- com.commercetools.sync.types.utils.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 theLocalizedString
name values of aType
and aTypeDraft
and returns anOptional
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 aType
and aTypeDraft
and returns a list ofUpdateAction
<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 theLocalizedString
descriptions of aType
and aTypeDraft
and returns anUpdateAction
<Type
> as a result in anOptional
of update action if values are different.
-
-
-
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 theLocalizedString
name values of aType
and aTypeDraft
and returns anOptional
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 theLocalizedString
descriptions of aType
and aTypeDraft
and returns anUpdateAction
<Type
> as a result in anOptional
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 aType
and aTypeDraft
and returns a list ofUpdateAction
<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
- 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.
-
-