it.amattioli.workstate.actions
Interface Guard

Show UML class diagram
All Known Implementing Classes:
AbstractGuard, BeanShellGuard, NegatedGuard, NullGuard

public interface Guard

A guard is a condition that allows a choice between various transitions having the same start state and the same triggering event.

Author:
andrea

Method Summary
 boolean check(AttributeReader event, AttributeReader state)
          Check if the condition is satisfied or not.
 Integer getPriority()
          Return the priority level for the guard evaluation.
 

Method Detail

check

boolean check(AttributeReader event,
              AttributeReader state)
Check if the condition is satisfied or not. The check can be performed using event parameters and state attributes.

Parameters:
event - the event that triggered the transition to which this guard is associated
state - the state that completely contains the transition to which this guard is associated

getPriority

Integer getPriority()
Return the priority level for the guard evaluation. To choose the right transition to trigger all the guards must be evaluated to know which is true. Normally all the guards should be indipendent one each other and the evaluation order should not be important. But to implement an "else" mechanism a priority has been associated to the guards. The null guard has a very low priority while all user defined guards have a high priority. In this way the null guard is always evaluated as the last guard and, as it always returns true, it works like an "else" branch. The priority should not be used for other purposes like forcing the evaluation order of user defined guards.



Copyright © 2011. All Rights Reserved.