Thanks everyone for your suggestions. I agree with Earnie that Steve's
example is very clean and works like a charm.
J
--
View this message in context:
http://drools-java-rules-engine.46999.n3.nabble.com/collection-question-tp982769p984439.html
Sent from the Drools - User mailing list archive
Very clean.
Earnie!
From: Steve Ronderos
To: Rules Users List
Sent: Wed, July 21, 2010 9:56:56 AM
Subject: Re: [rules-users] collection question
Hi J,
In your example I don't think that the collect is necessary.
I believe the following will work:
ed the collects because you are just checking for
existence/non-existence of facts within the products collection.
Good luck!
Steve
rules-users-boun...@lists.jboss.org wrote on 07/21/2010 01:59:40 AM:
> From:
>
> Wolfgang Laun
>
> To:
>
> Rules Users List
>
>
Things would be smpler if you could avoid re-creating Product objects
because adding an identical Object does not change the Set. (This
could be implemented with the help of a global Map,)
Second, overriding equals (and hashCode) in Product would also avoid adding
an "evil twin" in your rule code
Product bonusCd = new Product();
bonusCd.setName("bonus_cd");
productSet.add(bonusCd);
modify($so) {
setProducts(productSet);
}
end
From: javaj
To: rules-users@lists.jboss.org
Sent: Tue, July 20, 2010 6:4
I'm trying to write a rule to add an object to a collection if the collection
already contained a certain object with a specific attribute.
I developed a small example so maybe that will make more sense:
Use Case: In a product shipping applicaiton, anytime a product with the name
"cd1" is in the