class StateMachine {

    public T set(T newState)
    {
        T oldState = trySet(newState);
        checkState(oldState.equals(newState) || !isTerminalState(oldState), "%s cannot transition from %s to %s", name, state, newState);
        return oldState;
    }

    public  StateMachine(String name, Executor executor, T initialState);
    public  StateMachine(String name, Executor executor, T initialState, Iterable<T> terminalStates);

}