2 * Sone - ReplyImpl.java - Copyright © 2011–2013 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.impl;
20 import net.pterodactylus.sone.data.Reply;
21 import net.pterodactylus.sone.data.Sone;
24 * Abstract base class for all replies.
27 * The type of the reply
28 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
30 public abstract class ReplyImpl<T extends Reply<T>> implements Reply<T> {
32 /** The ID of the reply. */
33 private final String id;
35 /** The Sone that created this reply. */
36 private final Sone sone;
38 /** The time of the reply. */
39 private final long time;
41 /** The text of the reply. */
42 private final String text;
44 /** Whether the reply is known. */
45 private volatile boolean known;
48 * Creates a new reply.
53 * The Sone of the reply
55 * The time of the reply
57 * The text of the reply
59 protected ReplyImpl(String id, Sone sone, long time, String text) {
70 public String getId() {
78 public Sone getSone() {
86 public long getTime() {
94 public String getText() {
102 public boolean isKnown() {
110 @SuppressWarnings("unchecked")
111 public T setKnown(boolean known) {
124 public int hashCode() {
125 return id.hashCode();
132 public boolean equals(Object object) {
133 if (!(object instanceof Reply<?>)) {
136 Reply<?> reply = (Reply<?>) object;
137 return reply.getId().equals(id);
144 public String toString() {
145 return getClass().getName() + "[id=" + id + ",sone=" + sone + ",time=" + time + ",text=" + text + "]";