source: josm/trunk/src/org/openstreetmap/josm/data/notes/NoteComment.java@ 12479

Last change on this file since 12479 was 11878, checked in by Don-vip, 7 years ago

findbugs - EI_EXPOSE_REP2 + javadoc

  • Property svn:eol-style set to native
File size: 3.0 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data.notes;
3
4import java.util.Comparator;
5import java.util.Date;
6
7import org.openstreetmap.josm.data.osm.User;
8import org.openstreetmap.josm.tools.date.DateUtils;
9
10/**
11 * Represents a comment made on a note. All notes have at least on comment
12 * which is the comment the note was opened with. Comments are immutable.
13 * @since 7451
14 */
15public class NoteComment {
16
17 private final String text;
18 private final User user;
19 private final Date commentTimestamp;
20 private final Action action;
21
22 //not currently used. I'm planning on using this to keep track of new actions that need to be uploaded
23 private boolean isNew;
24
25 /**
26 * Every comment has an associated action. Some comments are just comments
27 * while others indicate the note being opened, closed or reopened
28 */
29 public enum Action {
30 /** note has been opened */
31 OPENED,
32 /** note has been closed */
33 CLOSED,
34 /** note has been reopened */
35 REOPENED,
36 /** note has been commented */
37 COMMENTED,
38 /** note has been hidden */
39 HIDDEN
40 }
41
42 /** Sorts note comments strictly by creation date */
43 public static final Comparator<NoteComment> DATE_COMPARATOR = (n1, n2) -> n1.commentTimestamp.compareTo(n2.commentTimestamp);
44
45 /**
46 * @param createDate The time at which this comment was added
47 * @param user JOSM User object of the user who created the comment
48 * @param commentText The text left by the user. Is sometimes blank
49 * @param action The action associated with this comment
50 * @param isNew Whether or not this comment is new and needs to be uploaded
51 */
52 public NoteComment(Date createDate, User user, String commentText, Action action, boolean isNew) {
53 this.text = commentText;
54 this.user = user;
55 this.commentTimestamp = DateUtils.cloneDate(createDate);
56 this.action = action;
57 this.isNew = isNew;
58 }
59
60 /** @return Plain text of user's comment */
61 public String getText() {
62 return text;
63 }
64
65 /** @return JOSM's User object for the user who made this comment */
66 public User getUser() {
67 return user;
68 }
69
70 /** @return The time at which this comment was created */
71 public Date getCommentTimestamp() {
72 return DateUtils.cloneDate(commentTimestamp);
73 }
74
75 /** @return the action associated with this note */
76 public Action getNoteAction() {
77 return action;
78 }
79
80 /**
81 * Sets whether this is a new comment/action and needs to be uploaded to the API
82 * @param isNew {@code true} if this is a new comment/action and needs to be uploaded to the API
83 */
84 public void setNew(boolean isNew) {
85 this.isNew = isNew;
86 }
87
88 /** @return true if this is a new comment/action and needs to be uploaded to the API */
89 public boolean isNew() {
90 return isNew;
91 }
92
93 @Override
94 public String toString() {
95 return text;
96 }
97}
Note: See TracBrowser for help on using the repository browser.