[rules-users] Question on contains operator with integer
Enda J Diggins
ejdiggins at gmail.com
Thu Mar 11 07:03:25 EST 2010
Hi,
'contains' works with collections. You can't put primitives into a
collection in java without wrapping them up in a class like Integer, Long,
Short, etc.
http://java.sun.com/j2se/1.5.0/docs/guide/language/autoboxing.html
Cheers,
Enda
On Wed, Mar 10, 2010 at 9:08 PM, cwolfinger <chase.wolfinger at gmail.com>wrote:
>
> Hello - I have a question on how to a contains operation with primitive
> values. What I have is a message that has a field called intTest that is a
> List<Integer>. If i do an intTest contains 4 check, then check compiles
> but
> it never matches. However if I do an eval it does work. Does anyone know
> how to use a primitive in a contains.
>
>
> Here is a sample of the rule:
>
> package com.sample
>
> import com.sample.DroolsTest.Message;
>
> rule "Test" salience 9999
> #when Message( eval(intTest.contains(Integer.valueOf(4))))
> when Message( intTest contains 4)
> then
> System.out.println("Found 4");
> end
> --
> View this message in context:
> http://n3.nabble.com/Question-on-contains-operator-with-integer-tp440559p440559.html
> Sent from the Drools - User mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
--
Enda J Diggins
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20100311/14dbb374/attachment.html
More information about the rules-users
mailing list