Class CommonTypeUpdateActionUtils


  • public final class CommonTypeUpdateActionUtils
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T extends io.sphere.sdk.models.ResourceIdentifier,​S extends io.sphere.sdk.models.ResourceIdentifier>
      boolean
      areResourceIdentifiersEqual​(T oldResourceIdentifier, S newResourceIdentifier)
      Compares the ids of two objects that are of type ResourceIdentifier (or a type that extends it).
      static <T,​S,​U extends io.sphere.sdk.commands.UpdateAction<T>>
      java.util.Optional<U>
      buildUpdateAction​(S oldObject, S newObject, java.util.function.Supplier<U> updateActionSupplier)
      Compares two Object and returns a supplied UpdateAction as a result in an Optional.
      static <T,​S extends io.sphere.sdk.models.ResourceIdentifier,​U extends io.sphere.sdk.models.ResourceIdentifier,​V extends io.sphere.sdk.commands.UpdateAction<T>>
      java.util.Optional<V>
      buildUpdateActionForReferences​(S oldResourceIdentifier, U newResourceIdentifier, java.util.function.Supplier<V> updateActionSupplier)
      Compares two objects that are of type ResourceIdentifier (or a type that extends it) and returns a supplied UpdateAction as a result in an Optional.
      static <T,​S,​U extends io.sphere.sdk.commands.UpdateAction<T>>
      java.util.List<U>
      buildUpdateActions​(S oldObject, S newObject, java.util.function.Supplier<java.util.List<U>> updateActionSupplier)
      Compares two Object and returns a supplied list of UpdateAction as a result.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • buildUpdateAction

        @Nonnull
        public static <T,​S,​U extends io.sphere.sdk.commands.UpdateAction<T>> java.util.Optional<U> buildUpdateAction​(@Nullable
                                                                                                                                 S oldObject,
                                                                                                                                 @Nullable
                                                                                                                                 S newObject,
                                                                                                                                 @Nonnull
                                                                                                                                 java.util.function.Supplier<U> updateActionSupplier)
        Compares two Object and returns a supplied UpdateAction as a result in an Optional. If both the Objects have the same values, then no update action is needed and hence an empty Optional is returned.
        Type Parameters:
        T - the type of the UpdateAction
        S - the type of the objects to compare
        U - certain UpdateAction implementation type
        Parameters:
        oldObject - the object which should be updated
        newObject - the object with the new information
        updateActionSupplier - the supplier that returns the update action to return in the optional
        Returns:
        A filled optional with the update action or an empty optional if the object values are identical
      • buildUpdateActionForReferences

        @Nonnull
        public static <T,​S extends io.sphere.sdk.models.ResourceIdentifier,​U extends io.sphere.sdk.models.ResourceIdentifier,​V extends io.sphere.sdk.commands.UpdateAction<T>> java.util.Optional<V> buildUpdateActionForReferences​(@Nullable
                                                                                                                                                                                                                                                      S oldResourceIdentifier,
                                                                                                                                                                                                                                                      @Nullable
                                                                                                                                                                                                                                                      U newResourceIdentifier,
                                                                                                                                                                                                                                                      @Nonnull
                                                                                                                                                                                                                                                      java.util.function.Supplier<V> updateActionSupplier)
        Compares two objects that are of type ResourceIdentifier (or a type that extends it) and returns a supplied UpdateAction as a result in an Optional. If both the Objects have the same values, then no update action is needed and hence an empty Optional is returned.
        Type Parameters:
        T - the type of the UpdateAction
        S - the type of the old resource identifier
        U - the type of the new resource identifier
        V - concrete UpdateAction implementation type
        Parameters:
        oldResourceIdentifier - the old resource identifier
        newResourceIdentifier - the new resource identifier
        updateActionSupplier - the supplier that returns the update action to return in the optional
        Returns:
        A filled optional with the update action or an empty optional if the object values are identical
      • areResourceIdentifiersEqual

        public static <T extends io.sphere.sdk.models.ResourceIdentifier,​S extends io.sphere.sdk.models.ResourceIdentifier> boolean areResourceIdentifiersEqual​(@Nullable
                                                                                                                                                                      T oldResourceIdentifier,
                                                                                                                                                                      @Nullable
                                                                                                                                                                      S newResourceIdentifier)
        Compares the ids of two objects that are of type ResourceIdentifier (or a type that extends it).
        Type Parameters:
        T - the type of the old resource identifier
        S - the type of the new resource identifier
        Parameters:
        oldResourceIdentifier - the old resource identifier
        newResourceIdentifier - the new resource identifier
        Returns:
        true or false depending if the resource identifiers have the same id.
      • buildUpdateActions

        @Nonnull
        public static <T,​S,​U extends io.sphere.sdk.commands.UpdateAction<T>> java.util.List<U> buildUpdateActions​(@Nullable
                                                                                                                              S oldObject,
                                                                                                                              @Nullable
                                                                                                                              S newObject,
                                                                                                                              @Nonnull
                                                                                                                              java.util.function.Supplier<java.util.List<U>> updateActionSupplier)
        Compares two Object and returns a supplied list of UpdateAction as a result. If both the Objects have the same values, then no update action is needed and hence an empty list is returned.
        Type Parameters:
        T - the type of the UpdateAction
        S - the type of the objects to compare
        U - certain UpdateAction implementation type
        Parameters:
        oldObject - the object which should be updated
        newObject - the object with the new information
        updateActionSupplier - the supplier that returns a list of update actions if the objects are different
        Returns:
        A filled optional with the update action or an empty optional if the object values are identical