Class StateUpdateActionUtils
- java.lang.Object
-
- com.commercetools.sync.states.utils.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 theinitial
values of aState
and aStateDraft
and returns anOptional
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 thetype
values of aState
and aStateDraft
and returns anOptional
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 aState
and aStateDraft
and returns a list ofStateUpdateAction
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 thedescription
values of aState
and aStateDraft
and returns anOptional
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 thename
values of aState
and aStateDraft
and returns anOptional
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 thetransitions
values of aState
and aStateDraft
and returns anOptional
of update action, which would contain the"setTransitions"
StateUpdateAction
.
-
-
-
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 thetype
values of aState
and aStateDraft
and returns anOptional
of update action, which would contain the"changeType"
StateUpdateAction
. If bothState
andStateDraft
have the sametype
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 thename
values of aState
and aStateDraft
and returns anOptional
of update action, which would contain the"setName"
StateUpdateAction
. If bothState
andStateDraft
have the samename
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 thedescription
values of aState
and aStateDraft
and returns anOptional
of update action, which would contain the"setDescription"
StateUpdateAction
. If bothState
andStateDraft
have the samedescription
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 theinitial
values of aState
and aStateDraft
and returns anOptional
of update action, which would contain the"changeInitial"
StateUpdateAction
. If bothState
andStateDraft
have the sameinitial
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 aState
and aStateDraft
and returns a list ofStateUpdateAction
as a result. If both theState
and theStateDraft
have identical roles, then no update action is needed and hence an emptyList
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 thetransitions
values of aState
and aStateDraft
and returns anOptional
of update action, which would contain the"setTransitions"
StateUpdateAction
. If bothState
andStateDraft
have the sametransitions
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
- theState
which should be updated.newState
- theStateDraft
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.
-
-