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 <ReferenceT extends com.commercetools.api.models.common.Reference,ResourceIdentifierT extends com.commercetools.api.models.common.ResourceIdentifier>
booleanareResourceIdentifiersEqual(ReferenceT oldReference, ResourceIdentifierT newResourceIdentifier)
Compares the ids of two objects that are of typeReference
andResourceIdentifier
(or a type that extends it).static <AnyT,ResourceUpdateActionT extends com.commercetools.api.models.ResourceUpdateAction<ResourceUpdateActionT>>
java.util.Optional<ResourceUpdateActionT>buildUpdateAction(AnyT oldObject, AnyT newObject, java.util.function.Supplier<ResourceUpdateActionT> updateActionSupplier)
Compares twoObject
and returns a suppliedResourceUpdateAction
as a result in anOptional
.static <ReferenceT extends com.commercetools.api.models.common.Reference,ResourceIdentifierT extends com.commercetools.api.models.common.ResourceIdentifier,ResourceUpdateActionT extends com.commercetools.api.models.ResourceUpdateAction<ResourceUpdateActionT>>
java.util.Optional<ResourceUpdateActionT>buildUpdateActionForReferences(ReferenceT oldReference, ResourceIdentifierT newResourceIdentifier, java.util.function.Supplier<ResourceUpdateActionT> updateActionSupplier)
Compares two objects that are of typeReference
andResourceIdentifier
(or a type that extends it) and returns a suppliedResourceUpdateAction
as a result in anOptional
.static <AnyT,ResourceUpdateActionT extends com.commercetools.api.models.ResourceUpdateAction<ResourceUpdateActionT>>
java.util.List<ResourceUpdateActionT>buildUpdateActions(AnyT oldObject, AnyT newObject, java.util.function.Supplier<java.util.List<ResourceUpdateActionT>> updateActionSupplier)
Compares twoObject
and returns a supplied list ofResourceUpdateAction
as a result.
-
-
-
Method Detail
-
buildUpdateAction
@Nonnull public static <AnyT,ResourceUpdateActionT extends com.commercetools.api.models.ResourceUpdateAction<ResourceUpdateActionT>> java.util.Optional<ResourceUpdateActionT> buildUpdateAction(@Nullable AnyT oldObject, @Nullable AnyT newObject, @Nonnull java.util.function.Supplier<ResourceUpdateActionT> updateActionSupplier)
Compares twoObject
and returns a suppliedResourceUpdateAction
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:
AnyT
- the type of the objects to compareResourceUpdateActionT
- certainResourceUpdateAction
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 <ReferenceT extends com.commercetools.api.models.common.Reference,ResourceIdentifierT extends com.commercetools.api.models.common.ResourceIdentifier,ResourceUpdateActionT extends com.commercetools.api.models.ResourceUpdateAction<ResourceUpdateActionT>> java.util.Optional<ResourceUpdateActionT> buildUpdateActionForReferences(@Nullable ReferenceT oldReference, @Nullable ResourceIdentifierT newResourceIdentifier, @Nonnull java.util.function.Supplier<ResourceUpdateActionT> updateActionSupplier)
Compares two objects that are of typeReference
andResourceIdentifier
(or a type that extends it) and returns a suppliedResourceUpdateAction
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:
ReferenceT
- the type of the old referenceResourceIdentifierT
- the type of the new resource identifierResourceUpdateActionT
- concreteResourceUpdateAction
implementation type- Parameters:
oldReference
- the old referencenewResourceIdentifier
- 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 <ReferenceT extends com.commercetools.api.models.common.Reference,ResourceIdentifierT extends com.commercetools.api.models.common.ResourceIdentifier> boolean areResourceIdentifiersEqual(@Nullable ReferenceT oldReference, @Nullable ResourceIdentifierT newResourceIdentifier)
Compares the ids of two objects that are of typeReference
andResourceIdentifier
(or a type that extends it).- Type Parameters:
ReferenceT
- the type of the old referenceResourceIdentifierT
- the type of the new resource identifier- Parameters:
oldReference
- the old referencenewResourceIdentifier
- the new resource identifier- Returns:
- true or false depending if the reference and resource identifier have the same id.
-
buildUpdateActions
@Nonnull public static <AnyT,ResourceUpdateActionT extends com.commercetools.api.models.ResourceUpdateAction<ResourceUpdateActionT>> java.util.List<ResourceUpdateActionT> buildUpdateActions(@Nullable AnyT oldObject, @Nullable AnyT newObject, @Nonnull java.util.function.Supplier<java.util.List<ResourceUpdateActionT>> updateActionSupplier)
Compares twoObject
and returns a supplied list ofResourceUpdateAction
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:
AnyT
- the type of the objects to compareResourceUpdateActionT
- certainResourceUpdateAction
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
-
-