public class MethodTransition extends AbstractTransition
Transition which invokes a Method. The Method will
only be invoked if its argument types actually matches a subset of the
Event's argument types. The argument types are matched in order so
you must make sure the order of the method's arguments corresponds to the
order of the event's arguments.
If the first method argument type matches
Event the current Event will be bound to that argument. In
the same manner the second argument (or first if the method isn't interested
in the current Event) can have the StateContext type and will
in that case be bound to the current StateContext.
Normally you wouldn't create instances of this class directly but rather use the
Transition annotation to define the methods which should be used as
transitions in your state machine and then let StateMachineFactory create a
StateMachine for you.
| 构造器和说明 |
|---|
MethodTransition(java.lang.Object eventId,
java.lang.reflect.Method method,
java.lang.Object target)
|
MethodTransition(java.lang.Object eventId,
java.lang.Object target)
|
MethodTransition(java.lang.Object eventId,
State nextState,
java.lang.reflect.Method method,
java.lang.Object target)
|
MethodTransition(java.lang.Object eventId,
State nextState,
java.lang.Object target)
|
MethodTransition(java.lang.Object eventId,
State nextState,
java.lang.String methodName,
java.lang.Object target)
|
MethodTransition(java.lang.Object eventId,
java.lang.String methodName,
java.lang.Object target)
|
| 限定符和类型 | 方法和说明 |
|---|---|
boolean |
doExecute(Event event)
Executes this
Transition. |
boolean |
equals(java.lang.Object o) |
java.lang.reflect.Method |
getMethod() |
java.lang.Object |
getTarget() |
int |
hashCode() |
java.lang.String |
toString() |
execute, getNextStatepublic MethodTransition(java.lang.Object eventId,
State nextState,
java.lang.reflect.Method method,
java.lang.Object target)
public MethodTransition(java.lang.Object eventId,
java.lang.reflect.Method method,
java.lang.Object target)
eventId - the Event id.method - the target method.target - the target object.public MethodTransition(java.lang.Object eventId,
State nextState,
java.lang.Object target)
State as next state
and for the specified Event id. The target Method will
be the method in the specified target object with the same name as the
specified Event id.eventId - the Event id.nextState - the next State.target - the target object.NoSuchMethodException - if no method could be found with a name
equal to the Event id.AmbiguousMethodException - if more than one method was found with
a name equal to the Event id.public MethodTransition(java.lang.Object eventId,
java.lang.Object target)
State
for the specified Event id. The target Method will
be the method in the specified target object with the same name as the
specified Event id.eventId - the Event id.target - the target object.NoSuchMethodException - if no method could be found with a name
equal to the Event id.AmbiguousMethodException - if more than one method was found with
a name equal to the Event id.public MethodTransition(java.lang.Object eventId,
java.lang.String methodName,
java.lang.Object target)
eventId - the Event id.methodName - the name of the target Method.target - the target object.NoSuchMethodException - if the method could not be found.AmbiguousMethodException - if there are more than one method with
the specified name.public MethodTransition(java.lang.Object eventId,
State nextState,
java.lang.String methodName,
java.lang.Object target)
eventId - the Event id.nextState - the next State.methodName - the name of the target Method.target - the target object.NoSuchMethodException - if the method could not be found.AmbiguousMethodException - if there are more than one method with
the specified name.public java.lang.reflect.Method getMethod()
Method.public java.lang.Object getTarget()
public boolean doExecute(Event event)
AbstractTransitionTransition. This method doesn't have to check
if the Event's id matches because AbstractTransition.execute(Event) has
already made sure that that is the case.doExecute 在类中 AbstractTransitionevent - the current Event.Transition has been executed
successfully and the StateMachine should move to the
next State. false otherwise.public boolean equals(java.lang.Object o)
equals 在类中 AbstractTransitionpublic int hashCode()
hashCode 在类中 AbstractTransitionpublic java.lang.String toString()
toString 在类中 AbstractTransition