Thanks Mark, sounds good. And the hashCode trick works. Wow, I would have never thought of that!
Mark Proctor wrote: > > D Brock wrote: >> I have defined the following rule to detect when duplicate objects (in >> this >> example, Widgets) exist. This always produces two matches, and therefore >> two messages. I understand why this occurs, but I would like for only >> one >> message to be reported. I cannot retract one of the widgets after a >> match >> b/c all are needed for additional rules matching. Is the a conventional >> way >> for accomplishing the elimination of the reciprocal match? >> >> rule "Do not allow duplicate widgets" >> when >> $w : Widget( $name : name ) >> Widget( this != $w, name == $name ) >> then >> System.out.println( "Duplicate widgets found with name = " + >> $name ); >> end >> > We are looking into a new conditional element that can achieve this. The > idea is when you use this CE, it ensures only a single permutation will > be propagated. In the meantime you can probably try something like: > > $w : Widget( $name : name ) > Widget( this != $w, hashCode < $w.hashCode, name == $name ) > > > > > _______________________________________________ > rules-users mailing list > [email protected] > https://lists.jboss.org/mailman/listinfo/rules-users > > -- View this message in context: http://old.nabble.com/Suppressing-reciprocal-matches-tp26230834p26241896.html Sent from the drools - user mailing list archive at Nabble.com. _______________________________________________ rules-users mailing list [email protected] https://lists.jboss.org/mailman/listinfo/rules-users
