Class StateMachine.Builder<S extends Enum<S>>

    • Constructor Detail

      • Builder

        public Builder​(@NonNull
                       Class<S> klass,
                       @NonNull
                       S initialState,
                       @Nullable
                       S errorState)
        State machine builder. The error state is treated specially: it is always legal to transition into the error state and never legal to transfer out of it.
        Parameters:
        klass - The class of the enum of states.
        initialState - The start state for the machine.
        errorState - The machine error state.
    • Method Detail

      • addTransition

        @NonNull
        @SafeVarargs
        public final StateMachine.Builder<S> addTransition​(@NonNull
                                                           S source,
                                                           @NonNull
                                                           S target1,
                                                           @NonNull
                                                           S... targets)
        Add arcs to the DAG. I believe that the use of varargs is, in fact, safe.
        Parameters:
        source - of the arcs.
        target1 - the end of the first arc
        targets - the ends of other arcs
      • build

        @NonNull
        public StateMachine<S> build()
        Create the state machine.
        Returns:
        a new state machine instance.