Comment: implement full hashCode and equals
The previous stub implementation dates back to when this class was
initially added in 10ba6179, but there doesn't appear to be a good
reason for it, and it's not consistent with PatchLineComment.
Change-Id: I73da6ae9a6f59bce9016260dfc9d0bd7d76b6ec7
diff --git a/java/com/google/gerrit/reviewdb/client/Comment.java b/java/com/google/gerrit/reviewdb/client/Comment.java
index 207643e..ce51dde 100644
--- a/java/com/google/gerrit/reviewdb/client/Comment.java
+++ b/java/com/google/gerrit/reviewdb/client/Comment.java
@@ -283,15 +283,41 @@
@Override
public boolean equals(Object o) {
- if (o instanceof Comment) {
- return Objects.equals(key, ((Comment) o).key);
+ if (!(o instanceof Comment)) {
+ return false;
}
- return false;
+ Comment c = (Comment) o;
+ return Objects.equals(key, c.key)
+ && lineNbr == c.lineNbr
+ && Objects.equals(author, c.author)
+ && Objects.equals(realAuthor, c.realAuthor)
+ && Objects.equals(writtenOn, c.writtenOn)
+ && side == c.side
+ && Objects.equals(message, c.message)
+ && Objects.equals(parentUuid, c.parentUuid)
+ && Objects.equals(range, c.range)
+ && Objects.equals(tag, c.tag)
+ && Objects.equals(revId, c.revId)
+ && Objects.equals(serverId, c.serverId)
+ && unresolved == c.unresolved;
}
@Override
public int hashCode() {
- return key.hashCode();
+ return Objects.hash(
+ key,
+ lineNbr,
+ author,
+ realAuthor,
+ writtenOn,
+ side,
+ message,
+ parentUuid,
+ range,
+ tag,
+ revId,
+ serverId,
+ unresolved);
}
@Override