Class 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>
      boolean
      areResourceIdentifiersEqual​(ReferenceT oldReference, ResourceIdentifierT newResourceIdentifier)
      Compares the ids of two objects that are of type Reference and ResourceIdentifier (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 two Object and returns a supplied ResourceUpdateAction as a result in an Optional.
      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 type Reference and ResourceIdentifier (or a type that extends it) and returns a supplied ResourceUpdateAction as a result in an Optional.
      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 two Object and returns a supplied list of ResourceUpdateAction 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 <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 two Object and returns a supplied ResourceUpdateAction 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:
        AnyT - the type of the objects to compare
        ResourceUpdateActionT - certain ResourceUpdateAction 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 <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 type Reference and ResourceIdentifier (or a type that extends it) and returns a supplied ResourceUpdateAction 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:
        ReferenceT - the type of the old reference
        ResourceIdentifierT - the type of the new resource identifier
        ResourceUpdateActionT - concrete ResourceUpdateAction implementation type
        Parameters:
        oldReference - the old reference
        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 <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 type Reference and ResourceIdentifier (or a type that extends it).
        Type Parameters:
        ReferenceT - the type of the old reference
        ResourceIdentifierT - the type of the new resource identifier
        Parameters:
        oldReference - the old reference
        newResourceIdentifier - 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 two Object and returns a supplied list of ResourceUpdateAction 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:
        AnyT - the type of the objects to compare
        ResourceUpdateActionT - certain ResourceUpdateAction 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