it.amattioli.workstate.actions
Class BeanShellGuard
java.lang.Object
it.amattioli.workstate.actions.AbstractGuard
it.amattioli.workstate.actions.BeanShellGuard
- All Implemented Interfaces:
- Guard
public class BeanShellGuard
- extends AbstractGuard
A guard implemented using a BeanShell script. This class allows to create
a guard using a Java expression written in a string without creating a
new class. The expression:
- must be BeanShell compatible
- must have a boolean return value
- can use state attributes and event parameters as variables
For example, if "attr1" is the name of a state attribute and "param1" is the
name of an event parameter you can create a guard with:
new BeanShellGuard("attr1.equals(param1)");
|
Constructor Summary |
BeanShellGuard(String code)
Build a guard using a BeanShell expression written in a string |
BeanShellGuard
public BeanShellGuard(String code)
- Build a guard using a BeanShell expression written in a string
- Parameters:
code - a BeanShell expression with boolean return value
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
toString
public String toString()
- Overrides:
toString in class AbstractGuard
equals
public boolean equals(Object o)
- Overrides:
equals in class AbstractGuard
hashCode
public int hashCode()
- Overrides:
hashCode in class AbstractGuard
Copyright © 2011. All Rights Reserved.