Class CommonTypeUpdateActionUtils
- java.lang.Object
-
- com.commercetools.sync.commons.utils.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>
booleanareResourceIdentifiersEqual(T oldResourceIdentifier, S newResourceIdentifier)
Compares the ids of two objects that are of typeResourceIdentifier
(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 twoObject
and returns a suppliedUpdateAction
as a result in anOptional
.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 typeResourceIdentifier
(or a type that extends it) and returns a suppliedUpdateAction
as a result in anOptional
.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 twoObject
and returns a supplied list ofUpdateAction
as a result.
-
-
-
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 twoObject
and returns a suppliedUpdateAction
as a result in anOptional
. If both theObject
s have the same values, then no update action is needed and hence an emptyOptional
is returned.- Type Parameters:
T
- the type of theUpdateAction
S
- the type of the objects to compareU
- certainUpdateAction
implementation type- Parameters:
oldObject
- the object which should be updatednewObject
- the object with the new informationupdateActionSupplier
- 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 typeResourceIdentifier
(or a type that extends it) and returns a suppliedUpdateAction
as a result in anOptional
. If both theObject
s have the same values, then no update action is needed and hence an emptyOptional
is returned.- Type Parameters:
T
- the type of theUpdateAction
S
- the type of the old resource identifierU
- the type of the new resource identifierV
- concreteUpdateAction
implementation type- Parameters:
oldResourceIdentifier
- the old resource identifiernewResourceIdentifier
- the new resource identifierupdateActionSupplier
- 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 typeResourceIdentifier
(or a type that extends it).- Type Parameters:
T
- the type of the old resource identifierS
- the type of the new resource identifier- Parameters:
oldResourceIdentifier
- the old resource identifiernewResourceIdentifier
- 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 twoObject
and returns a supplied list ofUpdateAction
as a result. If both theObject
s have the same values, then no update action is needed and hence an empty list is returned.- Type Parameters:
T
- the type of theUpdateAction
S
- the type of the objects to compareU
- certainUpdateAction
implementation type- Parameters:
oldObject
- the object which should be updatednewObject
- the object with the new informationupdateActionSupplier
- 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
-
-