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