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 Post this reply refers to. */
34 private final Post post;
36 /** The time of the reply. */
37 private final long time;
39 /** The text of the reply. */
40 private final String text;
43 * Creates a new reply.
46 * The post to reply to
48 * The text of the reply
50 public Reply(Post post, String text) {
51 this(post, System.currentTimeMillis(), text);
55 * Creates a new reply-
58 * The post to reply to
60 * The time of the reply
62 * The text of the reply
64 public Reply(Post post, long time, String text) {
65 this(UUID.randomUUID(), post, time, text);
69 * Creates a new reply-
74 * The post to reply to
76 * The time of the reply
78 * The text of the reply
80 public Reply(UUID id, Post post, long time, String text) {
92 * Returns the ID of the reply.
94 * @return The ID of the reply
96 public String getId() {
101 * Returns the post this reply refers to.
103 * @return The post this reply refers to
105 public Post getPost() {
110 * Returns the time of the reply.
112 * @return The time of the reply (in milliseconds since Jan 1, 1970 UTC)
114 public long getTime() {
119 * Returns the text of the reply.
121 * @return The text of the reply
123 public String getText() {
135 public int hashCode() {
136 return post.hashCode() ^ id.hashCode();
143 public boolean equals(Object object) {
144 if (!(object instanceof Reply)) {
147 return ((Reply) object).post.equals(post) && ((Reply) object).id.equals(id);