From e49caa21132cbd15376f6e10a45cd7c02e9a5f4f Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Fri, 31 Jan 2020 11:46:10 +0100 Subject: [PATCH] Add equals/hashCode to StringCommandType #1211 --- .../core/dynamic/segment/CommandSegments.java | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/lettuce/core/dynamic/segment/CommandSegments.java b/src/main/java/io/lettuce/core/dynamic/segment/CommandSegments.java index 115b36b6e8..bf1fad9d42 100644 --- a/src/main/java/io/lettuce/core/dynamic/segment/CommandSegments.java +++ b/src/main/java/io/lettuce/core/dynamic/segment/CommandSegments.java @@ -43,8 +43,8 @@ public CommandSegments(List segments) { LettuceAssert.isTrue(!segments.isEmpty(), "Command segments must not be empty"); - this.segments = segments.size() > 1 ? Collections.unmodifiableList(segments.subList(1, segments.size())) : Collections - .emptyList(); + this.segments = segments.size() > 1 ? Collections.unmodifiableList(segments.subList(1, segments.size())) + : Collections.emptyList(); this.commandType = potentiallyResolveCommand(segments.get(0).asString()); } @@ -102,6 +102,23 @@ public String name() { public String toString() { return name(); } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (!(o instanceof StringCommandType)) + return false; + + StringCommandType that = (StringCommandType) o; + + return commandType.equals(that.commandType); + } + + @Override + public int hashCode() { + return commandType.hashCode(); + } } @Override