Add equals() and hashCode() to UserAtom
We are experiencing problems that may be rooted in atoms not comparing
correctly. We limit comparison to comparing the URI, which should help
avoiding to manage multiple versions of the same atom in collections.
@@ -121,4 +121,29 @@ public class UserAtom {
public void setState(AtomState state) {
this.state = state;
}
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((uri == null) ? 0 : uri.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ UserAtom other = (UserAtom) obj;
+ if (uri == null) {
+ if (other.uri != null)
+ return false;
+ } else if (!uri.equals(other.uri))
+ return false;
+ return true;
+ }
}
