Class 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 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 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. 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.