001// License: GPL. For details, see LICENSE file. 002package org.openstreetmap.josm.data.notes; 003 004import java.util.Date; 005 006import org.openstreetmap.josm.data.osm.User; 007 008/** 009 * Represents a comment made on a note. All notes have at least on comment 010 * which is the comment the note was opened with. Comments are immutable. 011 * @since 7451 012 */ 013public class NoteComment { 014 015 private final String text; 016 private final User user; 017 private final Date commentTimestamp; 018 private final Action action; 019 020 //not currently used. I'm planning on using this to keep track of new actions that need to be uploaded 021 private boolean isNew; 022 023 /** 024 * Every comment has an associated action. Some comments are just comments 025 * while others indicate the note being opened, closed or reopened 026 */ 027 public enum Action { 028 /** note has been opened */ 029 OPENED, 030 /** note has been closed */ 031 CLOSED, 032 /** note has been reopened */ 033 REOPENED, 034 /** note has been commented */ 035 COMMENTED, 036 /** note has been hidden */ 037 HIDDEN 038 } 039 040 /** 041 * @param createDate The time at which this comment was added 042 * @param user JOSM User object of the user who created the comment 043 * @param commentText The text left by the user. Is sometimes blank 044 * @param action The action associated with this comment 045 * @param isNew Whether or not this comment is new and needs to be uploaded 046 */ 047 public NoteComment(Date createDate, User user, String commentText, Action action, boolean isNew) { 048 this.text = commentText; 049 this.user = user; 050 this.commentTimestamp = createDate; 051 this.action = action; 052 this.isNew = isNew; 053 } 054 055 /** @return Plain text of user's comment */ 056 public String getText() { 057 return text; 058 } 059 060 /** @return JOSM's User object for the user who made this comment */ 061 public User getUser() { 062 return user; 063 } 064 065 /** @return The time at which this comment was created */ 066 public Date getCommentTimestamp() { 067 return commentTimestamp; 068 } 069 070 /** @return the action associated with this note */ 071 public Action getNoteAction() { 072 return action; 073 } 074 075 /** 076 * Sets whether this is a new comment/action and needs to be uploaded to the API 077 * @param isNew {@code true} if this is a new comment/action and needs to be uploaded to the API 078 */ 079 public void setNew(boolean isNew) { 080 this.isNew = isNew; 081 } 082 083 /** @return true if this is a new comment/action and needs to be uploaded to the API */ 084 public boolean isNew() { 085 return isNew; 086 } 087 088 @Override 089 public String toString() { 090 return text; 091 } 092}