[rules-users] Casting an Object value in the LHS
Chris Woodrow
woodrow.chris at gmail.com
Tue Apr 29 05:16:24 EDT 2008
You can use inline eval
$m : Measurement(
name == "Foo",
eval(value instanceof Number),
value < 10)
2008/4/28 <rrogers at us.imshealth.com>:
> 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
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20080429/73c11c6c/attachment.html
More information about the rules-users
mailing list