2 * Sone - PostImpl.java - Copyright © 2010–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 java.util.UUID;
22 import net.pterodactylus.sone.data.Post;
23 import net.pterodactylus.sone.data.Sone;
26 * A post is a short message that a user writes in his Sone to let other users
27 * know what is going on.
29 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
31 public class PostImpl implements Post {
33 /** The GUID of the post. */
34 private final UUID id;
36 /** The Sone this post belongs to. */
37 private final Sone sone;
39 /** The Sone of the recipient. */
40 private final Sone recipient;
42 /** The time of the post (in milliseconds since Jan 1, 1970 UTC). */
43 private final long time;
45 /** The text of the post. */
46 private final String text;
48 /** Whether the post is known. */
49 private volatile boolean known;
57 * The Sone this post belongs to
59 * The recipient of the post
61 * The time of the post (in milliseconds since Jan 1, 1970 UTC)
63 * The text of the post
65 public PostImpl(String id, Sone sone, Sone recipient, long time, String text) {
66 this.id = UUID.fromString(id);
68 this.recipient = recipient;
81 public String getId() {
89 public Sone getSone() {
97 public Sone getRecipient() {
105 public long getTime() {
113 public String getText() {
121 public boolean isKnown() {
129 public PostImpl setKnown(boolean known) {
142 public int hashCode() {
143 return id.hashCode();
150 public boolean equals(Object object) {
151 if (!(object instanceof PostImpl)) {
154 PostImpl post = (PostImpl) object;
155 return post.id.equals(id);
162 public String toString() {
163 return getClass().getName() + "[id=" + id + ",sone=" + sone + ",time=" + time + ",text=" + text + "]";