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