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.