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 | */
|
---|
12 | public class NoteComment {
|
---|
13 |
|
---|
14 | private final String text;
|
---|
15 | private final User user;
|
---|
16 | private final Date commentTimestamp;
|
---|
17 | private final Action action;
|
---|
18 |
|
---|
19 | //not currently used. I'm planning on using this to keep track of new actions that need to be uploaded
|
---|
20 | private boolean isNew;
|
---|
21 |
|
---|
22 | /**
|
---|
23 | * Every comment has an associated action. Some comments are just comments
|
---|
24 | * while others indicate the note being opened, closed or reopened
|
---|
25 | */
|
---|
26 | public enum Action {
|
---|
27 | opened,
|
---|
28 | closed,
|
---|
29 | reopened,
|
---|
30 | commented
|
---|
31 | }
|
---|
32 |
|
---|
33 | /**
|
---|
34 | * @param createDate The time at which this comment was added
|
---|
35 | * @param user JOSM User object of the user who created the comment
|
---|
36 | * @param commentText The text left by the user. Is sometimes blank
|
---|
37 | * @param action The action associated with this comment
|
---|
38 | * @param isNew Whether or not this comment is new and needs to be uploaded
|
---|
39 | */
|
---|
40 | public NoteComment(Date createDate, User user, String commentText, Action action, boolean isNew) {
|
---|
41 | this.text = commentText;
|
---|
42 | this.user = user;
|
---|
43 | this.commentTimestamp = createDate;
|
---|
44 | this.action = action;
|
---|
45 | this.isNew = isNew;
|
---|
46 | }
|
---|
47 |
|
---|
48 | /** @return Plain text of user's comment */
|
---|
49 | public String getText() {
|
---|
50 | return text;
|
---|
51 | }
|
---|
52 |
|
---|
53 | /** @return JOSM's User object for the user who made this comment */
|
---|
54 | public User getUser() {
|
---|
55 | return user;
|
---|
56 | }
|
---|
57 |
|
---|
58 | /** @return The time at which this comment was created */
|
---|
59 | public Date getCommentTimestamp() {
|
---|
60 | return commentTimestamp;
|
---|
61 | }
|
---|
62 |
|
---|
63 | /** @return the action associated with this note */
|
---|
64 | public Action getNoteAction() {
|
---|
65 | return action;
|
---|
66 | }
|
---|
67 |
|
---|
68 | public void setNew(boolean isNew) {
|
---|
69 | this.isNew = isNew;
|
---|
70 | }
|
---|
71 |
|
---|
72 | /** @return true if this is a new comment/action and needs to be uploaded to the API */
|
---|
73 | public boolean isNew() {
|
---|
74 | return isNew;
|
---|
75 | }
|
---|
76 | }
|
---|