Fix ALL the logging!
[Sone.git] / src / main / java / net / pterodactylus / sone / data / PostReply.java
1 /*
2  * Sone - PostReply.java - Copyright © 2010–2011 David Roden
3  *
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.
8  *
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.
13  *
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/>.
16  */
17
18 package net.pterodactylus.sone.data;
19
20 import java.util.UUID;
21
22 /**
23  * A reply is like a {@link Post} but can never be posted on its own, it always
24  * refers to another {@link Post}.
25  *
26  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
27  */
28 public class PostReply extends Reply<PostReply> {
29
30         /** The Post this reply refers to. */
31         private volatile Post post;
32
33         /**
34          * Creates a new reply.
35          *
36          * @param id
37          *            The ID of the reply
38          */
39         public PostReply(String id) {
40                 this(id, null, null, 0, null);
41         }
42
43         /**
44          * Creates a new reply.
45          *
46          * @param sone
47          *            The sone that posted the reply
48          * @param post
49          *            The post to reply to
50          * @param text
51          *            The text of the reply
52          */
53         public PostReply(Sone sone, Post post, String text) {
54                 this(sone, post, System.currentTimeMillis(), text);
55         }
56
57         /**
58          * Creates a new reply-
59          *
60          * @param sone
61          *            The sone that posted the reply
62          * @param post
63          *            The post to reply to
64          * @param time
65          *            The time of the reply
66          * @param text
67          *            The text of the reply
68          */
69         public PostReply(Sone sone, Post post, long time, String text) {
70                 this(UUID.randomUUID().toString(), sone, post, time, text);
71         }
72
73         /**
74          * Creates a new reply-
75          *
76          * @param sone
77          *            The sone that posted the reply
78          * @param id
79          *            The ID of the reply
80          * @param post
81          *            The post to reply to
82          * @param time
83          *            The time of the reply
84          * @param text
85          *            The text of the reply
86          */
87         public PostReply(String id, Sone sone, Post post, long time, String text) {
88                 super(id, sone, time, text);
89                 this.post = post;
90         }
91
92         //
93         // ACCESSORS
94         //
95
96         /**
97          * Returns the post this reply refers to.
98          *
99          * @return The post this reply refers to
100          */
101         public Post getPost() {
102                 return post;
103         }
104
105         /**
106          * Sets the post this reply refers to.
107          *
108          * @param post
109          *            The post this reply refers to
110          * @return This reply (for method chaining)
111          */
112         public PostReply setPost(Post post) {
113                 this.post = post;
114                 return this;
115         }
116
117 }