Line data Source code
1 : // Copyright (C) 2020 The Android Open Source Project 2 : // 3 : // Licensed under the Apache License, Version 2.0 (the "License"); 4 : // you may not use this file except in compliance with the License. 5 : // You may obtain a copy of the License at 6 : // 7 : // http://www.apache.org/licenses/LICENSE-2.0 8 : // 9 : // Unless required by applicable law or agreed to in writing, software 10 : // distributed under the License is distributed on an "AS IS" BASIS, 11 : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 : // See the License for the specific language governing permissions and 13 : // limitations under the License. 14 : 15 : package com.google.gerrit.entities; 16 : 17 : import java.time.Instant; 18 : import java.util.Objects; 19 : 20 : /** 21 : * This class represents inline human comments in NoteDb. This means it determines the JSON format 22 : * for inline comments in the revision notes that NoteDb uses to persist inline comments. 23 : * 24 : * <p>Changing fields in this class changes the storage format of inline comments in NoteDb and may 25 : * require a corresponding data migration (adding new optional fields is generally okay). 26 : * 27 : * <p>Consider updating {@link #getApproximateSize()} when adding/changing fields. 28 : */ 29 : public class HumanComment extends Comment { 30 : 31 : public boolean unresolved; 32 : 33 : public HumanComment( 34 : Key key, 35 : Account.Id author, 36 : Instant writtenOn, 37 : short side, 38 : String message, 39 : String serverId, 40 : boolean unresolved) { 41 30 : super(key, author, writtenOn, side, message, serverId); 42 30 : this.unresolved = unresolved; 43 30 : } 44 : 45 : public HumanComment(HumanComment comment) { 46 4 : super(comment); 47 4 : } 48 : 49 : @Override 50 : public int getApproximateSize() { 51 23 : return super.getCommentFieldApproximateSize(); 52 : } 53 : 54 : @Override 55 : public String toString() { 56 0 : return toStringHelper().add("unresolved", unresolved).toString(); 57 : } 58 : 59 : @Override 60 : public boolean equals(Object otherObject) { 61 13 : if (!(otherObject instanceof HumanComment)) { 62 2 : return false; 63 : } 64 13 : if (!super.equals(otherObject)) { 65 13 : return false; 66 : } 67 2 : HumanComment otherComment = (HumanComment) otherObject; 68 2 : return unresolved == otherComment.unresolved; 69 : } 70 : 71 : @Override 72 : public int hashCode() { 73 26 : return Objects.hash(super.hashCode(), unresolved); 74 : } 75 : }