public final class UnorderedCollectionSyncUtils
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static <T,S,U,V> java.util.List<io.sphere.sdk.commands.UpdateAction<T>> |
buildRemoveUpdateActions(java.util.List<U> oldResources,
java.util.List<V> newDrafts,
java.util.function.Function<U,S> oldResourceKeyMapper,
java.util.function.Function<V,S> draftKeyMapper,
java.util.function.Function<U,io.sphere.sdk.commands.UpdateAction<T>> removeUpdateActionMapper)
Compares a list of
newDrafts with a list of oldResources and for every missing
matching draft in the oldResources : a remove update action is created using the removeUpdateActionMapper . |
@Nonnull public static <T,S,U,V> java.util.List<io.sphere.sdk.commands.UpdateAction<T>> buildRemoveUpdateActions(@Nonnull java.util.List<U> oldResources, @Nullable java.util.List<V> newDrafts, @Nonnull java.util.function.Function<U,S> oldResourceKeyMapper, @Nonnull java.util.function.Function<V,S> draftKeyMapper, @Nonnull java.util.function.Function<U,io.sphere.sdk.commands.UpdateAction<T>> removeUpdateActionMapper)
newDrafts
with a list of oldResources
and for every missing
matching draft in the oldResources
: a remove update action is created using the removeUpdateActionMapper
. The final result is a list of all the remove update actions.
The resulting list of update actions is ensured to contain no null values.
If the draft has null key as defined by draftKeyMapper
, the method will ignore
generating a remove update action for it.
T
- type of the resulting update actions.S
- type of the new resource key.U
- type of the old resource.V
- type of the new resource.oldResources
- a list of the old resource to compare to the new collection.newDrafts
- a list of the new drafts to compare to the old collection.oldResourceKeyMapper
- a function that uses the old resource to get its key matcher.draftKeyMapper
- a function that uses the draft to get its key matcher.removeUpdateActionMapper
- a function that uses the old resource to build a remove update
action.