Skip to content
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 4 commits into from Feb 27, 2018
Merged

Conversation

aytchell
Copy link
Contributor

@aytchell aytchell commented Jun 9, 2016

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 feature was implemented in three steps:

  • Add actions to 'permit' and 'permitIf'
  • Add actions to 'permitReentry' and 'permitReentryIf'
  • Add actions to 'permitDynamic' and 'permitDynamicIf'

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.

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 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.
@aytchell
Copy link
Contributor Author

The commits of this PR are also contained in #54 (implementation of #17) because #17 was built up on #15.

@Ktar5
Copy link
Contributor

Ktar5 commented Feb 19, 2018

@aytchell Would you be able to describe which PR you'd want merged? Would it be #55 or #54 ?

@aytchell
Copy link
Contributor Author

The commits added by PR #54 are a superset of those added by #55.
So adding #54 will be sufficient to have it all.

It's been a while since I opened these PRs so I'm sorry I can't say much about why the smaller id contains the bigger id but that's what the commit history says.

@Ktar5 Ktar5 merged commit 6dcf118 into stateless4j:master Feb 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants