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<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.states.State>> buildChangeInitialAction​(io.sphere.sdk.states.State oldState, io.sphere.sdk.states.StateDraft newState)
      Compares the initial values of a State and a StateDraft and returns an Optional of update action, which would contain the "changeInitial" UpdateAction.
      static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.states.State>> buildChangeTypeAction​(io.sphere.sdk.states.State oldState, io.sphere.sdk.states.StateDraft newState)
      Compares the type values of a State and a StateDraft and returns an Optional of update action, which would contain the "changeType" UpdateAction.
      static java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.states.State>> buildRolesUpdateActions​(io.sphere.sdk.states.State oldState, io.sphere.sdk.states.StateDraft newState)
      Compares the roles of a State and a StateDraft and returns a list of UpdateAction<State> as a result.
      static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.states.State>> buildSetDescriptionAction​(io.sphere.sdk.states.State oldState, io.sphere.sdk.states.StateDraft newState)
      Compares the description values of a State and a StateDraft and returns an Optional of update action, which would contain the "setDescription" UpdateAction.
      static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.states.State>> buildSetNameAction​(io.sphere.sdk.states.State oldState, io.sphere.sdk.states.StateDraft newState)
      Compares the name values of a State and a StateDraft and returns an Optional of update action, which would contain the "setName" UpdateAction.
      static java.util.Optional<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.states.State>> buildSetTransitionsAction​(io.sphere.sdk.states.State oldState, io.sphere.sdk.states.StateDraft newState)
      Compares the transitions values of a State and a StateDraft and returns an Optional of update action, which would contain the "setTransitions" UpdateAction.
      • 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<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.states.State>> buildChangeTypeAction​(@Nonnull
                                                                                                                                io.sphere.sdk.states.State oldState,
                                                                                                                                @Nonnull
                                                                                                                                io.sphere.sdk.states.StateDraft newState)
        Compares the type values of a State and a StateDraft and returns an Optional of update action, which would contain the "changeType" UpdateAction. 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<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.states.State>> buildSetNameAction​(@Nonnull
                                                                                                                             io.sphere.sdk.states.State oldState,
                                                                                                                             @Nonnull
                                                                                                                             io.sphere.sdk.states.StateDraft newState)
        Compares the name values of a State and a StateDraft and returns an Optional of update action, which would contain the "setName" UpdateAction. 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<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.states.State>> buildSetDescriptionAction​(@Nonnull
                                                                                                                                    io.sphere.sdk.states.State oldState,
                                                                                                                                    @Nonnull
                                                                                                                                    io.sphere.sdk.states.StateDraft newState)
        Compares the description values of a State and a StateDraft and returns an Optional of update action, which would contain the "setDescription" UpdateAction. 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<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.states.State>> buildChangeInitialAction​(@Nonnull
                                                                                                                                   io.sphere.sdk.states.State oldState,
                                                                                                                                   @Nonnull
                                                                                                                                   io.sphere.sdk.states.StateDraft newState)
        Compares the initial values of a State and a StateDraft and returns an Optional of update action, which would contain the "changeInitial" UpdateAction. 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<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.states.State>> buildRolesUpdateActions​(@Nonnull
                                                                                                                              io.sphere.sdk.states.State oldState,
                                                                                                                              @Nonnull
                                                                                                                              io.sphere.sdk.states.StateDraft newState)
        Compares the roles of a State and a StateDraft and returns a list of UpdateAction<State> 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<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.states.State>> buildSetTransitionsAction​(@Nonnull
                                                                                                                                    io.sphere.sdk.states.State oldState,
                                                                                                                                    @Nonnull
                                                                                                                                    io.sphere.sdk.states.StateDraft newState)
        Compares the transitions values of a State and a StateDraft and returns an Optional of update action, which would contain the "setTransitions" UpdateAction. 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.