[rules-users] Casting an Object value in the LHS

rrogers at us.imshealth.com rrogers at us.imshealth.com
Mon Apr 28 12:38:52 EDT 2008


Suppose I have a "Measurement" class, with a getName() method that
returns a String and with a getValue() method that returns an Object.
Sometimes the Object is a String, sometimes a Integer, sometimes a
Double.  I know that a "Foo" Measurement must be an integer, so I could
cast (or otherwise coerce) into a form that can be compared with a
constant integer (or other "Foo" Measurement).
 
How do I handle this type of value in the LHS of the rule?
 
when
    $m : Measurement(name == "Foo", value < 10)
then
    System.out.println("It's less than ten!");
end
 
I'd also like to be able to test for the Objects type (instanceof). I'm
using java as my dialect, if that makes a difference.   For other
reasons I'd like to avoid having to either subclass Measurement or add
type-specific value accessors.
 
-Russ
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20080428/083cb927/attachment.html 


More information about the rules-users mailing list