Class EnumValuesUpdateActionUtils


  • public final class EnumValuesUpdateActionUtils
    extends java.lang.Object
    The utils in this class are 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 <T extends io.sphere.sdk.models.WithKey,​U>
      java.util.List<io.sphere.sdk.commands.UpdateAction<U>>
      buildActions​(java.lang.String definitionName, java.util.List<T> oldEnumValues, java.util.List<T> newEnumValues, java.util.function.BiFunction<java.lang.String,​java.util.List<java.lang.String>,​io.sphere.sdk.commands.UpdateAction<U>> removeEnumCallback, TriFunction<java.lang.String,​T,​T,​java.util.List<io.sphere.sdk.commands.UpdateAction<U>>> matchingEnumCallback, java.util.function.BiFunction<java.lang.String,​T,​io.sphere.sdk.commands.UpdateAction<U>> addEnumCallback, java.util.function.BiFunction<java.lang.String,​java.util.List<T>,​io.sphere.sdk.commands.UpdateAction<U>> changeOrderEnumCallback, java.util.function.BiFunction<java.lang.String,​java.util.List<java.lang.String>,​io.sphere.sdk.commands.UpdateAction<U>> changeOrderWithKeysEnumCallback)
      Compares a list of old oldEnumValues with a list of new newEnumValues for a given definition.
      • Methods inherited from class java.lang.Object

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

      • buildActions

        @Nonnull
        public static <T extends io.sphere.sdk.models.WithKey,​U> java.util.List<io.sphere.sdk.commands.UpdateAction<U>> buildActions​(@Nonnull
                                                                                                                                           java.lang.String definitionName,
                                                                                                                                           @Nonnull
                                                                                                                                           java.util.List<T> oldEnumValues,
                                                                                                                                           @Nullable
                                                                                                                                           java.util.List<T> newEnumValues,
                                                                                                                                           @Nullable
                                                                                                                                           java.util.function.BiFunction<java.lang.String,​java.util.List<java.lang.String>,​io.sphere.sdk.commands.UpdateAction<U>> removeEnumCallback,
                                                                                                                                           @Nullable
                                                                                                                                           TriFunction<java.lang.String,​T,​T,​java.util.List<io.sphere.sdk.commands.UpdateAction<U>>> matchingEnumCallback,
                                                                                                                                           @Nullable
                                                                                                                                           java.util.function.BiFunction<java.lang.String,​T,​io.sphere.sdk.commands.UpdateAction<U>> addEnumCallback,
                                                                                                                                           @Nullable
                                                                                                                                           java.util.function.BiFunction<java.lang.String,​java.util.List<T>,​io.sphere.sdk.commands.UpdateAction<U>> changeOrderEnumCallback,
                                                                                                                                           @Nullable
                                                                                                                                           java.util.function.BiFunction<java.lang.String,​java.util.List<java.lang.String>,​io.sphere.sdk.commands.UpdateAction<U>> changeOrderWithKeysEnumCallback)
        Compares a list of old oldEnumValues with a list of new newEnumValues for a given definition. The method serves as an implementation for enum values syncing. The method takes in functions for building the required update actions (AddEnumValue, ChangeEnumValueOrder and 1-1 update actions on enum values (e.g. changeLabel) for the required resource.
        Type Parameters:
        T - the enum type of the elements to change the order for.
        U - the type of the resource in which the update actions will be applied on.
        Parameters:
        definitionName - the definition name whose enum values are going to be synced.
        oldEnumValues - the old list of plain enum values.
        newEnumValues - the new list of plain enum values.
        removeEnumCallback - the function that is called in order to remove the new enum instance.
        matchingEnumCallback - the function that is called to get the update action resulting from comparing the enum value fields one by one.
        addEnumCallback - the function that is called in order to add the new enum instance.
        changeOrderEnumCallback - the function that is called to apply the change in the order.
        changeOrderWithKeysEnumCallback - the function that is called to apply the change in the order with keys.
        Returns:
        a list of 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.