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 Sone that posted this reply. */
31 private final Sone sone;
33 /** The ID of the reply. */
34 private final UUID id;
36 /** The Post this reply refers to. */
37 private final Post post;
39 /** The time of the reply. */
40 private final long time;
42 /** The text of the reply. */
43 private final String text;
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(sone, UUID.randomUUID(), 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(Sone sone, UUID id, Post post, long time, String text) {
102 * Returns the Sone that posted this reply.
104 * @return The Sone that posted this reply
106 public Sone getSone() {
111 * Returns the ID of the reply.
113 * @return The ID of the reply
115 public String getId() {
116 return id.toString();
120 * Returns the post this reply refers to.
122 * @return The post this reply refers to
124 public Post getPost() {
129 * Returns the time of the reply.
131 * @return The time of the reply (in milliseconds since Jan 1, 1970 UTC)
133 public long getTime() {
138 * Returns the text of the reply.
140 * @return The text of the reply
142 public String getText() {
154 public int hashCode() {
155 return sone.hashCode() ^ id.hashCode() ^ post.hashCode() ^ (int) (time >> 32) ^ (int) (time & 0xffffffff);
162 public boolean equals(Object object) {
163 if (!(object instanceof Reply)) {
166 Reply reply = (Reply) object;
167 return reply.sone.equals(sone) && reply.id.equals(id) && reply.post.equals(post) && (reply.time == time) && reply.text.equals(text);