<br> Eric,<br><br> For now, the way to do identity checks is to use an inline eval:<br><br>when<br> $a : Fact()<br> $b : Fact( eval( $a == $b ) )<br>then<br> // $a and $b are identical<br>end<br><br> []s<br>
Edson<br><br><div><span class="gmail_quote">2007/10/18, Eric Miles <<a href="mailto:eric.miles@kronos.com">eric.miles@kronos.com</a>>:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
In java, I can check to see if a 2 variables references the same<br>instance as such:<br><br>Object a = new Object();<br>Object b = a;<br><br>a == b<br><br><br><br><br>Is there a way to do this in Drools? For instance, if there is an
<br>object in working memory and it is a specific instance, I do not want to<br>fire the rule again. ie:<br><br>rule "User Lookup UserKey"<br> salience 10000<br> when<br> com.kronos.taws.model.User
(empId == null, $key:empIdKey)<br> then<br> System.out.println("Firing 2!");<br> insert($key);<br><br>end<br><br>I want to ensure that $key is not already in working memory. But mind<br>you, there might be other $keys that are in working memory that do not
<br>belong to this particular com.kronos.taws.model.User instance. I do not<br>want this rule to fire because I have subsequent rules that will make<br>empId a value other than null.<br><br>I attempted to do this:<br><br>
rule "User Lookup UserKey"<br> when<br> com.kronos.taws.model.User(empId == null, $key:empIdKey)<br> not UserKey(this == $key)<br> then<br> System.out.println
("Firing 2!");<br> insert($key);<br><br>end<br><br>However, I still think this is doing an equality check because once the<br>$key object is updated in another rule, this rule is fired again!<br><br>
Thanks in advance!<br>Eric<br><br>_______________________________________________<br>rules-users mailing list<br><a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br><a href="https://lists.jboss.org/mailman/listinfo/rules-users">
https://lists.jboss.org/mailman/listinfo/rules-users</a><br></blockquote></div><br><br clear="all"><br>-- <br> Edson Tirelli<br> Software Engineer - JBoss Rules Core Developer<br> Office: +55 11 3529-6000<br> Mobile: +55 11 9287-5646
<br> JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a>