Class StateUpdateActionUtils


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

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.Optional<com.commercetools.api.models.state.StateUpdateAction> buildChangeInitialAction​(com.commercetools.api.models.state.State oldState, com.commercetools.api.models.state.StateDraft newState)
      Compares the initial values of a State and a StateDraft and returns an Optional of update action, which would contain the "changeInitial" StateUpdateAction.
      static java.util.Optional<com.commercetools.api.models.state.StateUpdateAction> buildChangeTypeAction​(com.commercetools.api.models.state.State oldState, com.commercetools.api.models.state.StateDraft newState)
      Compares the type values of a State and a StateDraft and returns an Optional of update action, which would contain the "changeType" StateUpdateAction.
      static java.util.List<com.commercetools.api.models.state.StateUpdateAction> buildRolesUpdateActions​(com.commercetools.api.models.state.State oldState, com.commercetools.api.models.state.StateDraft newState)
      Compares the roles of a State and a StateDraft and returns a list of StateUpdateAction as a result.
      static java.util.Optional<com.commercetools.api.models.state.StateUpdateAction> buildSetDescriptionAction​(com.commercetools.api.models.state.State oldState, com.commercetools.api.models.state.StateDraft newState)
      Compares the description values of a State and a StateDraft and returns an Optional of update action, which would contain the "setDescription" StateUpdateAction.
      static java.util.Optional<com.commercetools.api.models.state.StateUpdateAction> buildSetNameAction​(com.commercetools.api.models.state.State oldState, com.commercetools.api.models.state.StateDraft newState)
      Compares the name values of a State and a StateDraft and returns an Optional of update action, which would contain the "setName" StateUpdateAction.
      static java.util.Optional<com.commercetools.api.models.state.StateUpdateAction> buildSetTransitionsAction​(com.commercetools.api.models.state.State oldState, com.commercetools.api.models.state.StateDraft newState)
      Compares the transitions values of a State and a StateDraft and returns an Optional of update action, which would contain the "setTransitions" StateUpdateAction.
      • Methods inherited from class java.lang.Object

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

      • buildChangeTypeAction

        @Nonnull
        public static java.util.Optional<com.commercetools.api.models.state.StateUpdateAction> buildChangeTypeAction​(@Nonnull
                                                                                                                     com.commercetools.api.models.state.State oldState,
                                                                                                                     @Nonnull
                                                                                                                     com.commercetools.api.models.state.StateDraft newState)
        Compares the type values of a State and a StateDraft and returns an Optional of update action, which would contain the "changeType" StateUpdateAction. If both State and StateDraft have the same type values, then no update action is needed and empty optional will be returned.
        Parameters:
        oldState - the state that should be updated.
        newState - the state draft which contains the new type.
        Returns:
        optional containing update action or empty optional if types are identical.
      • buildSetNameAction

        @Nonnull
        public static java.util.Optional<com.commercetools.api.models.state.StateUpdateAction> buildSetNameAction​(@Nonnull
                                                                                                                  com.commercetools.api.models.state.State oldState,
                                                                                                                  @Nonnull
                                                                                                                  com.commercetools.api.models.state.StateDraft newState)
        Compares the name values of a State and a StateDraft and returns an Optional of update action, which would contain the "setName" StateUpdateAction. If both State and StateDraft have the same name values, then no update action is needed and empty optional will be returned.
        Parameters:
        oldState - the state that should be updated.
        newState - the state draft which contains the new name.
        Returns:
        optional containing update action or empty optional if names are identical.
      • buildSetDescriptionAction

        @Nonnull
        public static java.util.Optional<com.commercetools.api.models.state.StateUpdateAction> buildSetDescriptionAction​(@Nonnull
                                                                                                                         com.commercetools.api.models.state.State oldState,
                                                                                                                         @Nonnull
                                                                                                                         com.commercetools.api.models.state.StateDraft newState)
        Compares the description values of a State and a StateDraft and returns an Optional of update action, which would contain the "setDescription" StateUpdateAction. If both State and StateDraft have the same description values, then no update action is needed and empty optional will be returned.
        Parameters:
        oldState - the state that should be updated.
        newState - the state draft which contains the new description.
        Returns:
        optional containing update action or empty optional if descriptions are identical.
      • buildChangeInitialAction

        @Nonnull
        public static java.util.Optional<com.commercetools.api.models.state.StateUpdateAction> buildChangeInitialAction​(@Nonnull
                                                                                                                        com.commercetools.api.models.state.State oldState,
                                                                                                                        @Nonnull
                                                                                                                        com.commercetools.api.models.state.StateDraft newState)
        Compares the initial values of a State and a StateDraft and returns an Optional of update action, which would contain the "changeInitial" StateUpdateAction. If both State and StateDraft have the same initial values, then no update action is needed and empty optional will be returned.
        Parameters:
        oldState - the state that should be updated.
        newState - the state draft which contains the new initial.
        Returns:
        optional containing update action or empty optional if initial are identical.
      • buildRolesUpdateActions

        @Nonnull
        public static java.util.List<com.commercetools.api.models.state.StateUpdateAction> buildRolesUpdateActions​(@Nonnull
                                                                                                                   com.commercetools.api.models.state.State oldState,
                                                                                                                   @Nonnull
                                                                                                                   com.commercetools.api.models.state.StateDraft newState)
        Compares the roles of a State and a StateDraft and returns a list of StateUpdateAction as a result. If both the State and the StateDraft have identical roles, then no update action is needed and hence an empty List is returned.
        Parameters:
        oldState - the state which should be updated.
        newState - the state draft where we get the key.
        Returns:
        A list with the update actions or an empty list if the roles are identical.
      • buildSetTransitionsAction

        @Nonnull
        public static java.util.Optional<com.commercetools.api.models.state.StateUpdateAction> buildSetTransitionsAction​(@Nonnull
                                                                                                                         com.commercetools.api.models.state.State oldState,
                                                                                                                         @Nonnull
                                                                                                                         com.commercetools.api.models.state.StateDraft newState)
        Compares the transitions values of a State and a StateDraft and returns an Optional of update action, which would contain the "setTransitions" StateUpdateAction. If both State and StateDraft have the same transitions values, then no update action is needed and empty optional will be returned. if not, the transition of the old State gets overwritten with the transitions of the statedraft
        Parameters:
        oldState - the State which should be updated.
        newState - the StateDraft where we get the new data.
        Returns:
        optional containing update action or empty optional if there are no changes detected or there was an error.