it.amattioli.workstate.actions
Class NullGuard

Show UML class diagram
java.lang.Object
  extended by it.amattioli.workstate.actions.AbstractGuard
      extended by it.amattioli.workstate.actions.NullGuard
All Implemented Interfaces:
Guard

public class NullGuard
extends AbstractGuard

A guard whose check(AttributeReader, AttributeReader) method always returns true

Istances of NullGuard are used as null-objects. It is implemented as a singleton so to get an instance use the getInstance() factory method.


Field Summary
static Integer NULL_GUARD_PRIORITY
           
 
Fields inherited from class it.amattioli.workstate.actions.AbstractGuard
USER_PRIORITY
 
Method Summary
 boolean check(AttributeReader event, AttributeReader state)
          Check if the condition is satisfied or not.
static NullGuard getInstance()
           
 Integer getPriority()
          Return the priority level for the guard evaluation.
 
Methods inherited from class it.amattioli.workstate.actions.AbstractGuard
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

NULL_GUARD_PRIORITY

public static final Integer NULL_GUARD_PRIORITY
Method Detail

getInstance

public static NullGuard getInstance()

check

public boolean check(AttributeReader event,
                     AttributeReader state)
Description copied from interface: Guard
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

public Integer getPriority()
Description copied from interface: Guard
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.

Specified by:
getPriority in interface Guard
Overrides:
getPriority in class AbstractGuard


Copyright © 2011. All Rights Reserved.