New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue-15: Support action on transition #55
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Motivation ---------- UML state machine describes a transition as: ---- event [ guard ] / action ---> Current implementation of stateless4j only supports actions on entry and exit which is not the same. Modifications ------------- This commit adds code so one can attach an action to each 'normal' transition. 'Normal' means that I duplicated the two methods 'StateConfiguration.permit' and 'StateConfiguration.permitIf' and gave the copy an additional parameter of type 'Action'. This action is then executed (when the transition is taken) after the onExit-method of the current state and before the onEntry-method of the next state. Result ------ One can add an action to a static transition between two distinct nodes. This action gets called when the transition is taken.
Motivation ---------- UML state machine describes a transition as: ---- event [ guard ] / action ---> Current implementation of stateless4j only supports actions on entry and exit which is not the same. Modifications ------------- This commit adds the same functionality as the last but this time for re-entrant transitions. In detail this means that I duplicated the two methods 'StateConfiguration.permitReentry' and 'StateConfiguration.permitReentryIf' and gave the copy an additional parameter of type 'Action'. This action is then executed (when the transition is taken) between the onExit-method and the onEntry-method of the re-entered state. Result ------ One can add an action to a re-entrant transition (returning to the exact same node). This action gets called when the transition is taken.
Motivation ---------- UML state machine describes a transition as: ---- event [ guard ] / action ---> Current implementation of stateless4j only supports actions on entry and exit which is not the same. Modifications ------------- This commit adds actions to the dynamic transitions. In detail this means that I duplicated all the methods 'StateConfiguration.permitDynamic' and 'StateConfiguration.permitDynamicIf' (all in all that make eight new methods). I gave the copies additional parameters of type 'Action', 'Action1', 'Action2' and 'Action3' (depending on the method). The given action is then executed (when the transition is taken) between the onExit-method and the onEntry-method of the re-entered state. It will receive the parameters of the trigger (similar to the destinationStateSelectors). Result ------ One can add an action to a dynamic transition (those who compute their target based on the trigger's parameter). This action gets called when the transition is taken. The action will receive the parameters of the trigger.
aytchell
changed the title
Issue15: Support action on transition
Issue-15: Support action on transition
Jun 9, 2016
Finally added a short paragraph in the documentation about the new feature. Also extended the Java7 example to show the usage.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
UML state machine describes a transition as:
Current implementation of stateless4j only supports actions on entry and
exit which is not the same.
Modifications
This feature was implemented in three steps:
See the commit messages for details
Result
One can add an action to a transition which is executed if this transition is taken.
In case of a dynamic transition, the action will receive the parameters of trigger.