2 * Sone - PostReply.java - Copyright © 2010–2011 David Roden
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 package net.pterodactylus.sone.data;
20 import java.util.UUID;
23 * A reply is like a {@link Post} but can never be posted on its own, it always
24 * refers to another {@link Post}.
26 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
28 public class PostReply extends Reply<PostReply> {
30 /** The ID of the reply. */
31 private final UUID id;
33 /** The Sone that posted this reply. */
34 private volatile Sone sone;
36 /** The Post this reply refers to. */
37 private volatile Post post;
39 /** The time of the reply. */
40 private volatile long time;
42 /** The text of the reply. */
43 private volatile String text;
46 * Creates a new reply.
51 public PostReply(String id) {
52 this(id, null, null, 0, null);
56 * Creates a new reply.
59 * The sone that posted the reply
61 * The post to reply to
63 * The text of the reply
65 public PostReply(Sone sone, Post post, String text) {
66 this(sone, post, System.currentTimeMillis(), text);
70 * Creates a new reply-
73 * The sone that posted the reply
75 * The post to reply to
77 * The time of the reply
79 * The text of the reply
81 public PostReply(Sone sone, Post post, long time, String text) {
82 this(UUID.randomUUID().toString(), sone, post, time, text);
86 * Creates a new reply-
89 * The sone that posted the reply
93 * The post to reply to
95 * The time of the reply
97 * The text of the reply
99 public PostReply(String id, Sone sone, Post post, long time, String text) {
100 this.id = UUID.fromString(id);
115 public String getId() {
116 return id.toString();
123 public Sone getSone() {
128 * Sets the Sone that posted this reply.
131 * The Sone that posted this reply
132 * @return This reply (for method chaining)
134 public PostReply setSone(Sone sone) {
140 * Returns the post this reply refers to.
142 * @return The post this reply refers to
144 public Post getPost() {
149 * Sets the post this reply refers to.
152 * The post this reply refers to
153 * @return This reply (for method chaining)
155 public PostReply setPost(Post post) {
164 public long getTime() {
169 * Sets the time of this reply.
172 * The time of this reply (in milliseconds since Jan 1, 1970 UTC)
173 * @return This reply (for method chaining)
175 public PostReply setTime(long time) {
184 public String getText() {
189 * Sets the text of this reply.
192 * The text of this reply
193 * @return This reply (for method chaining)
195 public PostReply setText(String text) {
208 public int hashCode() {
209 return id.hashCode();
216 public boolean equals(Object object) {
217 if (!(object instanceof PostReply)) {
220 PostReply reply = (PostReply) object;
221 return reply.id.equals(id);
228 public String toString() {
229 return getClass().getName() + "[id=" + id + ",sone=" + sone + ",post=" + post + ",time=" + time + ",text=" + text + "]";