<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<a class="moz-txt-link-abbreviated" href="mailto:ringsah@comcast.net">ringsah@comcast.net</a> wrote:
<blockquote
 cite="mid:080520081812.5790.489897F2000B8BCC0000169E2209224627080E9C0902079D@comcast.net"
 type="cite">
  <div>I have a question about logical assertions and truth
maintenance. First of all, the Drools manual states:</div>
  <div>&nbsp;</div>
  <div>
  <div class="titlepage">
  <div>
  <div>
  <h4 class="title"><a moz-do-not-send="true" name="d0e1237"></a><font
 style="background-color: rgb(255, 255, 153);">2.5.8.2.&nbsp;Important note:
Equality for Java objects</font></h4>
  </div>
  </div>
  </div>
  <p><font style="background-color: rgb(255, 255, 153);">It is
important to note that for Truth Maintenance (and logical assertions)
to work at all, your Fact objects (which may be Javabeans) override
equals and hashCode methods (from java.lang.Object) correctly. As the
truth maintenance system needs to know when 2 different physical
objects are equal in value, BOTH equals and hashCode must be overridden
correctly, as per the Java standard.</font></p>
  <p><font style="background-color: rgb(255, 255, 153);">Two objects
are equal if and only if their equals methods return true for each
other and if their hashCode methods return the same values. See the
Java API for more details (but do keep in mind you MUST override both
equals and hashCode).</font></p>
  <p>Does this mean that in order to use logical assertions that I <em>have
  </em>to override equals and hashCode? </p>
  </div>
</blockquote>
TMS will work if you don't override logical/hashcode but it just means
it will always created a new logical relationship relationship. The
nice thing about impl equals and hashcode is it means if you try and
logical assert an object which is equal, it'll ignore it.<br>
<blockquote
 cite="mid:080520081812.5790.489897F2000B8BCC0000169E2209224627080E9C0902079D@comcast.net"
 type="cite">
  <div>
  <p>What if I have a class that I would like to use as fact in a
logical assertions, but for this class equality should be the same as
identity. In other words, I don't want to override equals and hashCode,
because the versions of these methods inherited from Object have the
correct&nbsp;behavior for my application. Will this class still be okay to
use as facts in logical assertions?</p>
  </div>
</blockquote>
It will work ok, but you need to make sure you understand the role of
equals/hashcode to stop fact duplication - it's pretty much like the
difference between an IdentityMap and HashMap.<br>
<blockquote
 cite="mid:080520081812.5790.489897F2000B8BCC0000169E2209224627080E9C0902079D@comcast.net"
 type="cite">
  <div>
  <p>Thanks,<br>
-Hans</p>
  </div>
  <pre wrap="">
<hr size="4" width="90%">
_______________________________________________
rules-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a>
  </pre>
</blockquote>
<br>
</body>
</html>