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.
49 * The sone that posted the reply
51 * The post to reply to
53 * The text of the reply
55 public Reply(Sone sone, Post post, String text) {
56 this(sone, post, System.currentTimeMillis(), text);
60 * Creates a new reply-
63 * The sone that posted the reply
65 * The post to reply to
67 * The time of the reply
69 * The text of the reply
71 public Reply(Sone sone, Post post, long time, String text) {
72 this(UUID.randomUUID().toString(), sone, post, time, text);
76 * Creates a new reply-
79 * The sone that posted the reply
83 * The post to reply to
85 * The time of the reply
87 * The text of the reply
89 public Reply(String id, Sone sone, Post post, long time, String text) {
90 this.id = UUID.fromString(id);
102 * Returns the ID of the reply.
104 * @return The ID of the reply
106 public String getId() {
107 return id.toString();
111 * Returns the Sone that posted this reply.
113 * @return The Sone that posted this reply
115 public Sone getSone() {
120 * Sets the Sone that posted this reply.
123 * The Sone that posted this reply
124 * @return This reply (for method chaining)
126 public Reply setSone(Sone sone) {
132 * Returns the post this reply refers to.
134 * @return The post this reply refers to
136 public Post getPost() {
141 * Sets the post this reply refers to.
144 * The post this reply refers to
145 * @return This reply (for method chaining)
147 public Reply setPost(Post post) {
153 * Returns the time of the reply.
155 * @return The time of the reply (in milliseconds since Jan 1, 1970 UTC)
157 public long getTime() {
162 * Sets the time of this reply.
165 * The time of this reply (in milliseconds since Jan 1, 1970 UTC)
166 * @return This reply (for method chaining)
168 public Reply setTime(long time) {
174 * Returns the text of the reply.
176 * @return The text of the reply
178 public String getText() {
183 * Sets the text of this reply.
186 * The text of this reply
187 * @return This reply (for method chaining)
189 public Reply setText(String text) {
202 public int hashCode() {
203 return sone.hashCode() ^ id.hashCode() ^ post.hashCode() ^ (int) (time >> 32) ^ (int) (time & 0xffffffff) ^ text.hashCode();
210 public boolean equals(Object object) {
211 if (!(object instanceof Reply)) {
214 Reply reply = (Reply) object;
215 return reply.sone.equals(sone) && reply.id.equals(id) && reply.post.equals(post) && (reply.time == time) && reply.text.equals(text);
222 public String toString() {
223 return getClass().getName() + "[id=" + id + ",sone=" + sone + ",post=" + post + ",time=" + time + ",text=" + text + "]";