it.amattioli.workstate.actions
Class NullGuard
java.lang.Object
it.amattioli.workstate.actions.AbstractGuard
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.
NULL_GUARD_PRIORITY
public static final Integer NULL_GUARD_PRIORITY
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 associatedstate - 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.