Skip to content
Snippets Groups Projects
Commit 13df22f6 authored by akwizgran's avatar akwizgran
Browse files

Better hashCode methods.

parent 47749c3c
No related branches found
No related tags found
No related merge requests found
......@@ -26,6 +26,11 @@ public class Transport {
return properties;
}
@Override
public int hashCode() {
return id.hashCode() ^ properties.hashCode();
}
@Override
public boolean equals(Object o) {
if(o instanceof Transport) {
......@@ -34,9 +39,4 @@ public class Transport {
}
return false;
}
@Override
public int hashCode() {
return id.hashCode();
}
}
......@@ -96,15 +96,17 @@ class PollerImpl implements Poller, Runnable {
this.plugin = plugin;
}
// Must be consistent with equals()
public int compareTo(PollTime p) {
if(time < p.time) return -1;
if(time > p.time) return 1;
return 0;
}
// Must be consistent with equals()
@Override
public int hashCode() {
return (int) time;
return (int) (time ^ (time >>> 32)) ^ plugin.hashCode();
}
@Override
......
......@@ -42,7 +42,8 @@ abstract class Frame {
@Override
public int hashCode() {
return (int) getSequenceNumber();
long sequenceNumber = getSequenceNumber();
return buf[0] ^ (int) (sequenceNumber ^ (sequenceNumber >>> 32));
}
@Override
......
......@@ -352,7 +352,7 @@ class KeyManagerImpl extends TimerTask implements KeyManager, DatabaseListener {
@Override
public int hashCode() {
return contactId.hashCode() + transportId.hashCode();
return contactId.hashCode() ^ transportId.hashCode();
}
@Override
......
......@@ -164,7 +164,7 @@ class TransportConnectionRecogniser {
@Override
public int hashCode() {
return contactId.hashCode() + (int) period;
return contactId.hashCode() ^ (int) (period ^ (period >>> 32));
}
@Override
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment