Add hashCode and equals override so that this object can be used in
collections properly
This commit is contained in:
Timothy Bish 2013-11-08 16:06:49 -05:00
parent 692428eee5
commit 8f078a3f4c
1 changed files with 29 additions and 0 deletions

View File

@ -114,6 +114,7 @@ public class ConsumerInfo extends BaseCommand {
return subscriptionName != null; return subscriptionName != null;
} }
@Override
public byte getDataStructureType() { public byte getDataStructureType() {
return DATA_STRUCTURE_TYPE; return DATA_STRUCTURE_TYPE;
} }
@ -343,6 +344,7 @@ public class ConsumerInfo extends BaseCommand {
this.additionalPredicate = additionalPredicate; this.additionalPredicate = additionalPredicate;
} }
@Override
public Response visit(CommandVisitor visitor) throws Exception { public Response visit(CommandVisitor visitor) throws Exception {
return visitor.processAddConsumer(this); return visitor.processAddConsumer(this);
} }
@ -434,6 +436,33 @@ public class ConsumerInfo extends BaseCommand {
return result; 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 * Tracks the original subscription id that causes a subscription to
* percolate through a network when networkTTL > 1. Tracking the original * percolate through a network when networkTTL > 1. Tracking the original