Skip to content

Commit

Permalink
Add equals/hashCode to StringCommandType #1211
Browse files Browse the repository at this point in the history
  • Loading branch information
mp911de committed Jan 31, 2020
1 parent df06111 commit e49caa2
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/main/java/io/lettuce/core/dynamic/segment/CommandSegments.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public CommandSegments(List<CommandSegment> 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());
}

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e49caa2

Please sign in to comment.