it.amattioli.workstate.actions
Class BeanShellGuard

Show UML class diagram
java.lang.Object
  extended by it.amattioli.workstate.actions.AbstractGuard
      extended by 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:

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)");


Field Summary
 
Fields inherited from class it.amattioli.workstate.actions.AbstractGuard
USER_PRIORITY
 
Constructor Summary
BeanShellGuard(String code)
          Build a guard using a BeanShell expression written in a string
 
Method Summary
 boolean check(AttributeReader event, AttributeReader state)
          Check if the condition is satisfied or not.
 boolean equals(Object o)
           
 int hashCode()
           
 String toString()
           
 
Methods inherited from class it.amattioli.workstate.actions.AbstractGuard
getPriority
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

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
Method Detail

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

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.