diff options
author | Jon Marius Venstad <venstad@gmail.com> | 2020-09-29 19:15:29 +0200 |
---|---|---|
committer | Jon Marius Venstad <venstad@gmail.com> | 2020-09-30 10:23:35 +0200 |
commit | 96c27a8107d572f624018f367a369989efa74f84 (patch) | |
tree | 78c56cb0a700681dc982244e7a3e7a5d3d3e5a48 /document | |
parent | 9a999a7a7b87d3c5f731c9c5a90d158b93359a1a (diff) |
Add equals and hashCode to some classes
Diffstat (limited to 'document')
-rw-r--r-- | document/abi-spec.json | 4 | ||||
-rw-r--r-- | document/src/main/java/com/yahoo/document/DocumentPut.java | 16 | ||||
-rw-r--r-- | document/src/main/java/com/yahoo/document/TestAndSetCondition.java | 14 |
3 files changed, 34 insertions, 0 deletions
diff --git a/document/abi-spec.json b/document/abi-spec.json index e53cf09f07e..c9191aa2fdb 100644 --- a/document/abi-spec.json +++ b/document/abi-spec.json @@ -399,6 +399,8 @@ "public com.yahoo.document.DocumentId getId()", "public void <init>(com.yahoo.document.DocumentPut)", "public void <init>(com.yahoo.document.DocumentPut, com.yahoo.document.Document)", + "public boolean equals(java.lang.Object)", + "public int hashCode()", "public java.lang.String toString()" ], "fields": [] @@ -1929,6 +1931,8 @@ "public java.lang.String getSelection()", "public boolean isPresent()", "public static com.yahoo.document.TestAndSetCondition fromConditionString(java.util.Optional)", + "public boolean equals(java.lang.Object)", + "public int hashCode()", "public java.lang.String toString()" ], "fields": [ diff --git a/document/src/main/java/com/yahoo/document/DocumentPut.java b/document/src/main/java/com/yahoo/document/DocumentPut.java index c5ce2e7e181..e24388cd65f 100644 --- a/document/src/main/java/com/yahoo/document/DocumentPut.java +++ b/document/src/main/java/com/yahoo/document/DocumentPut.java @@ -1,6 +1,8 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.document; +import java.util.Objects; + /** * @author Vegard Sjonfjell */ @@ -47,6 +49,20 @@ public class DocumentPut extends DocumentOperation { } @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + DocumentPut that = (DocumentPut) o; + return document.equals(that.document) && + getCondition().equals(that.getCondition()); + } + + @Override + public int hashCode() { + return Objects.hash(document, getCondition()); + } + + @Override public String toString() { return "put of document " + getId(); } diff --git a/document/src/main/java/com/yahoo/document/TestAndSetCondition.java b/document/src/main/java/com/yahoo/document/TestAndSetCondition.java index 6a189fc2969..a582807e38c 100644 --- a/document/src/main/java/com/yahoo/document/TestAndSetCondition.java +++ b/document/src/main/java/com/yahoo/document/TestAndSetCondition.java @@ -1,6 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.document; +import java.util.Objects; import java.util.Optional; /** @@ -43,6 +44,19 @@ public class TestAndSetCondition { } @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + TestAndSetCondition that = (TestAndSetCondition) o; + return conditionStr.equals(that.conditionStr); + } + + @Override + public int hashCode() { + return Objects.hash(conditionStr); + } + + @Override public String toString() { StringBuilder string = new StringBuilder(); string.append("condition '"); |