From 8f078a3f4ce0599f958c1363e55fbc966013cdba Mon Sep 17 00:00:00 2001 From: Timothy Bish Date: Fri, 8 Nov 2013 16:06:49 -0500 Subject: [PATCH] https://issues.apache.org/jira/browse/AMQ-4853 Add hashCode and equals override so that this object can be used in collections properly --- .../apache/activemq/command/ConsumerInfo.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/activemq-client/src/main/java/org/apache/activemq/command/ConsumerInfo.java b/activemq-client/src/main/java/org/apache/activemq/command/ConsumerInfo.java index 3e8ec54bdf..01f224390f 100755 --- a/activemq-client/src/main/java/org/apache/activemq/command/ConsumerInfo.java +++ b/activemq-client/src/main/java/org/apache/activemq/command/ConsumerInfo.java @@ -114,6 +114,7 @@ public class ConsumerInfo extends BaseCommand { return subscriptionName != null; } + @Override public byte getDataStructureType() { return DATA_STRUCTURE_TYPE; } @@ -343,6 +344,7 @@ public class ConsumerInfo extends BaseCommand { this.additionalPredicate = additionalPredicate; } + @Override public Response visit(CommandVisitor visitor) throws Exception { return visitor.processAddConsumer(this); } @@ -434,6 +436,33 @@ public class ConsumerInfo extends BaseCommand { return result; } + @Override + public int hashCode() { + return (consumerId == null) ? 0 : consumerId.hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + + ConsumerInfo other = (ConsumerInfo) obj; + + if (consumerId == null && other.consumerId != null) { + return false; + } else if (!consumerId.equals(other.consumerId)) { + return false; + } + return true; + } + /** * Tracks the original subscription id that causes a subscription to * percolate through a network when networkTTL > 1. Tracking the original