Class StateMachineUtils

java.lang.Object
org.springframework.statemachine.support.StateMachineUtils

public abstract class StateMachineUtils extends Object
Various utility methods for state machine.
Author:
Janne Valkealahti
  • Constructor Details

    • StateMachineUtils

      public StateMachineUtils()
  • Method Details

    • isSubstate

      public static <S, E> boolean isSubstate(State<S,E> left, State<S,E> right)
      Checks if right hand side is a substate of a left hand side.
      Type Parameters:
      S - the type of state
      E - the type of event
      Parameters:
      left - the super state
      right - the sub state
      Returns:
      if sub is child of super
    • containsAtleastOne

      public static <S> boolean containsAtleastOne(Collection<S> left, Collection<S> right)
      Checks if right hand collection has atleast one same item as left hand collection.
      Type Parameters:
      S - the generic type
      Parameters:
      left - the left collection
      right - the right collection
      Returns:
      true, right contains at least one item from left, false otherwise.
    • isNormalPseudoState

      public static <S, E> boolean isNormalPseudoState(State<S,E> state)
      Checks if state is a normal pseudo state, meaning it is a pseudostate and its kind is not initial or end.
      Type Parameters:
      S - the type of state
      E - the type of event
      Parameters:
      state - the state
      Returns:
      true, if is normal pseudo state
    • isTransientPseudoState

      public static <S, E> boolean isTransientPseudoState(State<S,E> state)
      Checks if state is a transient pseudo state, meaning it is a pseudostate and its kind indicates that machine will never stay on this state after run to completion has finished.
      Type Parameters:
      S - the type of state
      E - the type of event
      Parameters:
      state - the state
      Returns:
      true, if is normal pseudo state
    • isPseudoState

      public static <S, E> boolean isPseudoState(State<S,E> state, PseudoStateKind kind)
    • toStringCollection

      public static <S> Collection<String> toStringCollection(Collection<S> collection)
    • toStringCollection

      public static Collection<String> toStringCollection(Object object)
    • containsAtleastOneEqualString

      public static boolean containsAtleastOneEqualString(Collection<String> left, String right)
    • containsAtleastOneEqualString

      public static boolean containsAtleastOneEqualString(Collection<String> left, Collection<String> right)
    • getMessageHeaderDoActionTimeout

      public static <S, E> Long getMessageHeaderDoActionTimeout(StateContext<S,E> context)
      Gets a particular message header from a StateContext and parses it to Long. Any error parsing header results NULL.
      Type Parameters:
      S - the type of state
      E - the type of event
      Parameters:
      context - the state context
      Returns:
      the header as Long or NULL
    • resumeErrorToContext

      public static Function<? super Throwable,reactor.core.publisher.Mono<Void>> resumeErrorToContext()
      Utility function to stash error into reactor context.
      Returns:
      mono for completion