public class StateMachine
extends java.lang.Object
State
objects connected by Transition
s. Normally you wouldn't create
instances of this class directly but rather use the
State
annotation to define
your states and then let StateMachineFactory
create a
StateMachine
for you.构造器和说明 |
---|
StateMachine(java.util.Collection<State> states,
java.lang.String startStateId)
Creates a new instance using the specified
State s and start
state. |
StateMachine(State[] states,
java.lang.String startStateId)
Creates a new instance using the specified
State s and start
state. |
public StateMachine(State[] states, java.lang.String startStateId)
State
s and start
state.public State getState(java.lang.String id) throws NoSuchStateException
State
with the specified id.id
- the id of the State
to return.State
NoSuchStateException
- if no matching State
could be found.public java.util.Collection<State> getStates()
Collection
of all State
s used by
this StateMachine
.public void handle(Event event)
Event
through this StateMachine
.
Normally you wouldn't call this directly but rather use
StateMachineProxyBuilder
to create a proxy for an interface of
your choice. Any method calls on the proxy will be translated into
Event
objects and then fed to the StateMachine
by the
proxy using this method.event
- the Event
to be handled.