2 * Sone - Reply.java - Copyright © 2010 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>
30 /** The ID of the reply. */
31 private final UUID id;
33 /** The Sone that posted this reply. */
36 /** The Post this reply refers to. */
39 /** The time of the reply. */
42 /** The text of the reply. */
46 * Creates a new reply.
51 public Reply(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 Reply(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 Reply(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 Reply(String id, Sone sone, Post post, long time, String text) {
100 this.id = UUID.fromString(id);
112 * Returns the ID of the reply.
114 * @return The ID of the reply
116 public String getId() {
117 return id.toString();
121 * Returns the Sone that posted this reply.
123 * @return The Sone that posted this reply
125 public Sone getSone() {
130 * Sets the Sone that posted this reply.
133 * The Sone that posted this reply
134 * @return This reply (for method chaining)
136 public Reply setSone(Sone sone) {
142 * Returns the post this reply refers to.
144 * @return The post this reply refers to
146 public Post getPost() {
151 * Sets the post this reply refers to.
154 * The post this reply refers to
155 * @return This reply (for method chaining)
157 public Reply setPost(Post post) {
163 * Returns the time of the reply.
165 * @return The time of the reply (in milliseconds since Jan 1, 1970 UTC)
167 public long getTime() {
172 * Sets the time of this reply.
175 * The time of this reply (in milliseconds since Jan 1, 1970 UTC)
176 * @return This reply (for method chaining)
178 public Reply setTime(long time) {
184 * Returns the text of the reply.
186 * @return The text of the reply
188 public String getText() {
193 * Sets the text of this reply.
196 * The text of this reply
197 * @return This reply (for method chaining)
199 public Reply setText(String text) {
212 public int hashCode() {
213 return id.hashCode();
220 public boolean equals(Object object) {
221 if (!(object instanceof Reply)) {
224 Reply reply = (Reply) object;
225 return reply.id.equals(id);
232 public String toString() {
233 return getClass().getName() + "[id=" + id + ",sone=" + sone + ",post=" + post + ",time=" + time + ",text=" + text + "]";