Class StateMachine.Builder

  • Enclosing class:
    StateMachine

    public static final class StateMachine.Builder
    extends java.lang.Object
    Builder that builds a StateMachine.
    • Method Detail

      • addState

        public StateMachine.Builder addState​(java.lang.Enum stateEnum,
                                             java.lang.String description)
        Adds a state with name and description.
        Parameters:
        stateEnum - enumeration indicating the state
        description - description of the state
        Returns:
        the builder
        Throws:
        java.lang.RuntimeException - if the state was already added
      • setInitialState

        public StateMachine.Builder setInitialState​(java.lang.Enum stateToSet)
        Parameters:
        stateToSet - the initial state for StateMachine
        Returns:
        the builder
        Throws:
        java.lang.RuntimeException - if the initial state was not added first
      • addTransition

        public StateMachine.Builder addTransition​(java.lang.Enum from,
                                                  java.lang.Enum to,
                                                  java.lang.String description)
        Adds a transition with description.
        Parameters:
        from - from state name
        to - to state name
        description - description of the transition
        Returns:
        the builder
        Throws:
        java.lang.RuntimeException - if either from or to state was not added, or the same transition was already added
      • build

        public StateMachine build()
        Builds and returns the StateMachine.
        Returns:
        the StateMachine
        Throws:
        java.lang.RuntimeException - if an initial state was not set