source: josm/trunk/src/org/openstreetmap/josm/data/notes/Note.java@ 9067

Last change on this file since 9067 was 7509, checked in by stoecker, 10 years ago

remove tabs

  • Property svn:eol-style set to native
File size: 3.1 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data.notes;
3
4import java.util.ArrayList;
5import java.util.Date;
6import java.util.List;
7
8import org.openstreetmap.josm.data.coor.LatLon;
9
10/**
11 * A map note. It always has at least one comment since a comment is required
12 * to create a note on osm.org
13 */
14public class Note {
15
16 public enum State { open, closed }
17
18 private long id;
19 private LatLon latLon;
20 private Date createdAt;
21 private Date closedAt;
22 private State state;
23 private List<NoteComment> comments = new ArrayList<NoteComment>();
24
25 /**
26 * Create a note with a given location
27 * @param latLon Geographic location of this note
28 */
29 public Note(LatLon latLon) {
30 this.latLon = latLon;
31 }
32
33 /** @return The unique OSM ID of this note */
34 public long getId() {
35 return id;
36 }
37
38 public void setId(long id) {
39 this.id = id;
40 }
41
42 /** @return The geographic location of the note */
43 public LatLon getLatLon() {
44 return latLon;
45 }
46
47 /** @return Date that this note was submitted */
48 public Date getCreatedAt() {
49 return createdAt;
50 }
51
52 public void setCreatedAt(Date createdAt) {
53 this.createdAt = createdAt;
54 }
55
56 /** @return Date that this note was closed. Null if it is still open. */
57 public Date getClosedAt() {
58 return closedAt;
59 }
60
61 public void setClosedAt(Date closedAt) {
62 this.closedAt = closedAt;
63 }
64
65 /** @return The open or closed state of this note */
66 public State getState() {
67 return state;
68 }
69
70 public void setState(State state) {
71 this.state = state;
72 }
73
74 /** @return An ordered list of comments associated with this note */
75 public List<NoteComment> getComments() {
76 return comments;
77 }
78
79 public void addComment(NoteComment comment) {
80 this.comments.add(comment);
81 }
82
83 /**
84 * Returns the comment that was submitted by the user when creating the note
85 * @return First comment object
86 */
87 public NoteComment getFirstComment() {
88 return this.comments.get(0);
89 }
90
91 /**
92 * Copies values from a new note into an existing one. Used after a note
93 * has been updated on the server and the local copy needs refreshing.
94 * @param note New values to copy
95 */
96 public void updateWith(Note note) {
97 this.comments = note.comments;
98 this.createdAt = note.createdAt;
99 this.id = note.id;
100 this.state = note.state;
101 this.latLon = note.latLon;
102 }
103
104 @Override
105 public int hashCode() {
106 final int prime = 31;
107 int result = 1;
108 result = prime * result + (int) (id ^ (id >>> 32));
109 return result;
110 }
111
112 /** Compares notes by OSM ID */
113 @Override
114 public boolean equals(Object obj) {
115 if (this == obj)
116 return true;
117 if (obj == null)
118 return false;
119 if (getClass() != obj.getClass())
120 return false;
121 Note other = (Note) obj;
122 if (id != other.id)
123 return false;
124 return true;
125 }
126}
Note: See TracBrowser for help on using the repository browser.