Class Comment
- java.lang.Object
-
- com.google.gerrit.reviewdb.client.Comment
-
- Direct Known Subclasses:
RobotComment
public class Comment extends Object
This class represents inline comments in NoteDb. This means it determines the JSON format for inline comments in the revision notes that NoteDb uses to persist inline comments.Changing fields in this class changes the storage format of inline comments in NoteDb and may require a corresponding data migration (adding new optional fields is generally okay).
PatchLineComment
also represents inline comments, but in ReviewDb. There are a few notable differences:- PatchLineComment knows the comment status (published or draft). For comments in NoteDb the status is determined by the branch in which they are stored (published comments are stored in the change meta ref; draft comments are store in refs/draft-comments branches in All-Users). Hence Comment doesn't need to contain the status, but the status is implicitly known by where the comments are read from.
- PatchLineComment knows the change ID. For comments in NoteDb, the change ID is determined by the branch in which they are stored (the ref name contains the change ID). Hence Comment doesn't need to contain the change ID, but the change ID is implicitly known by where the comments are read from.
For all utility classes and middle layer functionality using Comment over PatchLineComment is preferred, as PatchLineComment will go away together with ReviewDb. This means Comment should be used everywhere and only for storing inline comment in ReviewDb a conversion to PatchLineComment is done. Converting Comments to PatchLineComments and vice verse is done by CommentsUtil#toPatchLineComments(Change.Id, PatchLineComment.Status, Iterable) and CommentsUtil#toComments(String, Iterable).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Comment.Identity
static class
Comment.Key
static class
Comment.Range
-
Field Summary
Fields Modifier and Type Field Description Comment.Identity
author
Comment.Key
key
boolean
legacyFormat
Whether the comment was parsed from a JSON representation (false) or the legacy custom notes format (true).int
lineNbr
String
message
String
parentUuid
Comment.Range
range
protected Comment.Identity
realAuthor
String
revId
String
serverId
short
side
String
tag
boolean
unresolved
Timestamp
writtenOn
-
Constructor Summary
Constructors Constructor Description Comment(Comment c)
Comment(Comment.Key key, Account.Id author, Timestamp writtenOn, short side, String message, String serverId, boolean unresolved)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
Comment.Identity
getRealAuthor()
int
hashCode()
void
setLineNbrAndRange(Integer lineNbr, Comment.Range range)
void
setRange(CommentRange range)
void
setRealAuthor(Account.Id id)
void
setRevId(RevId revId)
String
toString()
-
-
-
Field Detail
-
key
public Comment.Key key
-
lineNbr
public int lineNbr
-
author
public Comment.Identity author
-
realAuthor
protected Comment.Identity realAuthor
-
writtenOn
public Timestamp writtenOn
-
side
public short side
-
message
public String message
-
parentUuid
public String parentUuid
-
range
public Comment.Range range
-
tag
public String tag
-
revId
public String revId
-
serverId
public String serverId
-
unresolved
public boolean unresolved
-
legacyFormat
public transient boolean legacyFormat
Whether the comment was parsed from a JSON representation (false) or the legacy custom notes format (true).
-
-
Constructor Detail
-
Comment
public Comment(Comment c)
-
Comment
public Comment(Comment.Key key, Account.Id author, Timestamp writtenOn, short side, String message, String serverId, boolean unresolved)
-
-
Method Detail
-
setLineNbrAndRange
public void setLineNbrAndRange(Integer lineNbr, Comment.Range range)
-
setRange
public void setRange(CommentRange range)
-
setRevId
public void setRevId(RevId revId)
-
setRealAuthor
public void setRealAuthor(Account.Id id)
-
getRealAuthor
public Comment.Identity getRealAuthor()
-
-