Class MethodTransition
java.lang.Object
org.apache.mina.statemachine.transition.AbstractTransition
org.apache.mina.statemachine.transition.MethodTransition
- All Implemented Interfaces:
Transition
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.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMethodTransition(Object eventId, Object target) MethodTransition(Object eventId, Method method, Object target) MethodTransition(Object eventId, String methodName, Object target) MethodTransition(Object eventId, State nextState, Object target) MethodTransition(Object eventId, State nextState, Method method, Object target) MethodTransition(Object eventId, State nextState, String methodName, Object target) -
Method Summary
Modifier and TypeMethodDescriptionbooleanExecutes thisTransition.booleaninthashCode()private voidinvokeMethod(Object[] arguments) private booleantoString()Methods inherited from class AbstractTransition
execute, getNextState
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
EMPTY_ARGUMENTS
-
method
-
target
-
-
Constructor Details
-
MethodTransition
-
MethodTransition
-
MethodTransition
Creates a new instance with the specifiedStateas next state and for the specifiedEventid. The targetMethodwill be the method in the specified target object with the same name as the specifiedEventid.- Parameters:
eventId- theEventid.nextState- the nextState.target- the target object.- Throws:
NoSuchMethodException- if no method could be found with a name equal to theEventid.AmbiguousMethodException- if more than one method was found with a name equal to theEventid.
-
MethodTransition
Creates a new instance which will loopback to the sameStatefor the specifiedEventid. The targetMethodwill be the method in the specified target object with the same name as the specifiedEventid.- Parameters:
eventId- theEventid.target- the target object.- Throws:
NoSuchMethodException- if no method could be found with a name equal to theEventid.AmbiguousMethodException- if more than one method was found with a name equal to theEventid.
-
MethodTransition
- Parameters:
eventId- theEventid.methodName- the name of the targetMethod.target- the target object.- Throws:
NoSuchMethodException- if the method could not be found.AmbiguousMethodException- if there are more than one method with the specified name.
-
MethodTransition
- Parameters:
eventId- theEventid.nextState- the nextState.methodName- the name of the targetMethod.target- the target object.- Throws:
NoSuchMethodException- if the method could not be found.AmbiguousMethodException- if there are more than one method with the specified name.
-
-
Method Details
-
getMethod
-
getTarget
- Returns:
- the target object.
-
doExecute
Executes thisTransition. This method doesn't have to check if theEvent's id matches becauseAbstractTransition.execute(Event)has already made sure that that is the case.- Specified by:
doExecutein classAbstractTransition- Parameters:
event- the currentEvent.- Returns:
trueif theTransitionhas been executed successfully and theStateMachineshould move to the nextState.falseotherwise.
-
match
-
invokeMethod
-
equals
- Overrides:
equalsin classAbstractTransition
-
hashCode
public int hashCode()- Overrides:
hashCodein classAbstractTransition
-
toString
- Overrides:
toStringin classAbstractTransition
-