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 <WithKeyT extends com.commercetools.api.models.WithKey,​ResourceUpdateActionT extends com.commercetools.api.models.ResourceUpdateAction<ResourceUpdateActionT>>
      java.util.List<ResourceUpdateActionT>
      buildActions​(java.lang.String definitionName, java.util.List<WithKeyT> oldEnumValues, java.util.List<WithKeyT> newEnumValues, java.util.function.BiFunction<java.lang.String,​java.util.List<java.lang.String>,​ResourceUpdateActionT> removeEnumCallback, TriFunction<java.lang.String,​WithKeyT,​WithKeyT,​java.util.List<ResourceUpdateActionT>> matchingEnumCallback, java.util.function.BiFunction<java.lang.String,​WithKeyT,​ResourceUpdateActionT> addEnumCallback, java.util.function.BiFunction<java.lang.String,​java.util.List<WithKeyT>,​ResourceUpdateActionT> changeOrderEnumCallback, java.util.function.BiFunction<java.lang.String,​java.util.List<java.lang.String>,​ResourceUpdateActionT> 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 <WithKeyT extends com.commercetools.api.models.WithKey,​ResourceUpdateActionT extends com.commercetools.api.models.ResourceUpdateAction<ResourceUpdateActionT>> java.util.List<ResourceUpdateActionT> buildActions​(@Nonnull
                                                                                                                                                                                                                                              java.lang.String definitionName,
                                                                                                                                                                                                                                              @Nonnull
                                                                                                                                                                                                                                              java.util.List<WithKeyT> oldEnumValues,
                                                                                                                                                                                                                                              @Nullable
                                                                                                                                                                                                                                              java.util.List<WithKeyT> newEnumValues,
                                                                                                                                                                                                                                              @Nullable
                                                                                                                                                                                                                                              java.util.function.BiFunction<java.lang.String,​java.util.List<java.lang.String>,​ResourceUpdateActionT> removeEnumCallback,
                                                                                                                                                                                                                                              @Nullable
                                                                                                                                                                                                                                              TriFunction<java.lang.String,​WithKeyT,​WithKeyT,​java.util.List<ResourceUpdateActionT>> matchingEnumCallback,
                                                                                                                                                                                                                                              @Nullable
                                                                                                                                                                                                                                              java.util.function.BiFunction<java.lang.String,​WithKeyT,​ResourceUpdateActionT> addEnumCallback,
                                                                                                                                                                                                                                              @Nullable
                                                                                                                                                                                                                                              java.util.function.BiFunction<java.lang.String,​java.util.List<WithKeyT>,​ResourceUpdateActionT> changeOrderEnumCallback,
                                                                                                                                                                                                                                              @Nullable
                                                                                                                                                                                                                                              java.util.function.BiFunction<java.lang.String,​java.util.List<java.lang.String>,​ResourceUpdateActionT> 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:
        WithKeyT - the enum type of the elements to change the order for.
        ResourceUpdateActionT - 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.