You can use inline eval<br><br><span> <font face="Arial" size="2">$m : Measurement(<br></font></span><div style="margin-left: 40px;"><div style="margin-left: 40px;"><span><font face="Arial" size="2">name == "Foo", <br>
eval(value instanceof Number),<br></font></span></div><span></span></div><div style="margin-left: 80px;"><span><font face="Arial" size="2">value < 10)</font></span><br></div><br><div class="gmail_quote">2008/4/28 <<a href="mailto:rrogers@us.imshealth.com">rrogers@us.imshealth.com</a>>:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div>
<div><span><font face="Arial" size="2">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. <span><font face="Arial" size="2">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).</font></span></font></span></div>
<div><span><font face="Arial" size="2"></font></span> </div>
<div><span><font face="Arial" size="2">How do I handle this
type of value in the LHS of the rule?</font></span></div>
<div><span><font face="Arial" size="2"></font></span> </div>
<div><span><font face="Arial" size="2">when</font></span></div>
<div><span> <font face="Arial" size="2">$m : Measurement(name == "Foo", value < 10)</font></span></div>
<div><span><font face="Arial" size="2">then</font></span></div>
<div><span> <font face="Arial" size="2">System.out.println("It's less than ten!");</font></span></div>
<div><span><font face="Arial" size="2">end</font></span></div>
<div><span><font face="Arial" size="2"></font></span> </div>
<div><span><font face="Arial" size="2">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.</font></span></div>
<div><span><font face="Arial" size="2"></font></span> </div>
<div><span><font face="Arial" size="2">-Russ</font></span></div></div>
<br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br></blockquote></div><br>