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 )