Class UnorderedCollectionSyncUtils
- java.lang.Object
-
- com.commercetools.sync.internals.utils.UnorderedCollectionSyncUtils
-
public final class UnorderedCollectionSyncUtils extends java.lang.Object
This class is 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,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 ofnewDrafts
with a list ofoldResources
and for every missing matching draft in theoldResources
: a remove update action is created using theremoveUpdateActionMapper
.
-
-
-
Method Detail
-
buildRemoveUpdateActions
@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)
Compares a list ofnewDrafts
with a list ofoldResources
and for every missing matching draft in theoldResources
: a remove update action is created using theremoveUpdateActionMapper
. 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.- Type Parameters:
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.- Parameters:
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.- Returns:
- a list of all the remove update actions. If there are no missing matching drafts, an empty list is returned.
-
-