Line data Source code
1 : // Copyright (C) 2016 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.mail; 16 : 17 : import com.google.gerrit.entities.HumanComment; 18 : import java.util.Objects; 19 : 20 : /** A comment parsed from inbound email */ 21 : public class MailComment { 22 5 : public enum CommentType { 23 5 : PATCHSET_LEVEL, 24 5 : FILE_COMMENT, 25 5 : INLINE_COMMENT 26 : } 27 : 28 : CommentType type; 29 : HumanComment inReplyTo; 30 : String fileName; 31 : String message; 32 : boolean isLink; 33 : 34 3 : public MailComment() {} 35 : 36 : public MailComment( 37 1 : String message, String fileName, HumanComment inReplyTo, CommentType type, boolean isLink) { 38 1 : this.message = message; 39 1 : this.fileName = fileName; 40 1 : this.inReplyTo = inReplyTo; 41 1 : this.type = type; 42 1 : this.isLink = isLink; 43 1 : } 44 : 45 : public CommentType getType() { 46 2 : return type; 47 : } 48 : 49 : public HumanComment getInReplyTo() { 50 2 : return inReplyTo; 51 : } 52 : 53 : public String getFileName() { 54 1 : return fileName; 55 : } 56 : 57 : public String getMessage() { 58 2 : return message; 59 : } 60 : 61 : /** 62 : * Checks if the provided comment concerns the same exact spot in the change. This is basically an 63 : * equals method except that the message is not checked. 64 : */ 65 : public boolean isSameCommentPath(MailComment c) { 66 2 : return Objects.equals(fileName, c.fileName) 67 2 : && Objects.equals(inReplyTo, c.inReplyTo) 68 2 : && Objects.equals(type, c.type); 69 : } 70 : }