[rules-users] Can I do a Collection contains Collection?

Wolfgang Laun wolfgang.laun at gmail.com
Fri Feb 19 11:55:07 EST 2010


The line
   Set() from RefData.getConstantValues()
seems to imply that ConstantValues is a Collection<Set<?>>, but this
seems strange.

Assuming that ConstantValues is a plain Set<?>, the rule might be written as

rule "ex1"
when
   Example( $zips : zips )
   $zip : ZipCode() from $zips
   RefData(  constantValues not contains $zip )
then
   error()
end

or as

rule "ex2"
when
   Example( $zips : zips )
   RefData( eval( ! constantValues.containsAll( $zips ) ) )
then
   error()
end

which might be faster.
-W


On Fri, Feb 19, 2010 at 4:38 PM, EdenAEL20 <eden_mondragon at ml.com> wrote:
>
> I have an object coming in which contains a collection of id's. I want to
> verify these id's are in another collection. I'm looking for something like
> collection is a subset of another collection. any ideas??
>
> zips below is a collection, i want to verify that each zip is in $e1.
>
> rule "example"
>  when
>         e1: Set() from RefData.getConstantValues()
>         e2: Example( zips not in $e1)
>  then
>       error()
> --
> View this message in context: http://n3.nabble.com/Can-I-do-a-Collection-contains-Collection-tp217546p217546.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
>




More information about the rules-users mailing list