You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ta...@apache.org on 2014/10/03 23:17:28 UTC
[2/2] git commit: More correct equals and hashCode
More correct equals and hashCode
Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/81fc1e5d
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/81fc1e5d
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/81fc1e5d
Branch: refs/heads/master
Commit: 81fc1e5d2b77f370ce11b2cab82e198bb0a5c74e
Parents: 263c93d
Author: Timothy Bish <ta...@gmail.com>
Authored: Fri Oct 3 17:15:47 2014 -0400
Committer: Timothy Bish <ta...@gmail.com>
Committed: Fri Oct 3 17:15:47 2014 -0400
----------------------------------------------------------------------
.../org/apache/qpid/jms/JmsDestination.java | 23 +++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/81fc1e5d/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsDestination.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsDestination.java b/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsDestination.java
index a86e0f7..a736ed6 100644
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsDestination.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/JmsDestination.java
@@ -136,14 +136,31 @@ public abstract class JmsDestination extends JNDIStorable implements JmsResource
return false;
}
- JmsDestination d = (JmsDestination) o;
- return getName().equals(d.getName());
+ JmsDestination other = (JmsDestination) o;
+ if (name == null && other.name != null) {
+ return false;
+ } else if (!name.equals(other.name)) {
+ return false;
+ }
+
+ if (temporary != other.temporary) {
+ return false;
+ }
+ if (topic != other.topic) {
+ return false;
+ }
+
+ return true;
}
@Override
public int hashCode() {
if (hashValue == 0) {
- hashValue = getName().hashCode();
+ final int prime = 31;
+ hashValue = 1;
+ hashValue = prime * hashValue + ((name == null) ? 0 : name.hashCode());
+ hashValue = prime * hashValue + (temporary ? 1231 : 1237);
+ hashValue = prime * hashValue + (topic ? 1231 : 1237);
}
return hashValue;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org