Remove obsolete User class.
[Sone.git] / src / main / java / net / pterodactylus / sone / data / ReplyShell.java
1 /*
2  * Sone - ReplyShell.java - Copyright © 2010 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 shell around a {@link Reply} for replies that have not yet been retrieved
24  * from Freenet.
25  *
26  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
27  */
28 public class ReplyShell extends Reply implements Shell<Reply> {
29
30         /** The Sone that posted this reply. */
31         private Sone sone;
32
33         /** The ID of the reply. */
34         private UUID id;
35
36         /** The Post this reply refers to. */
37         private Post post;
38
39         /** The time of the reply. */
40         private Long time;
41
42         /** The text of the reply. */
43         private String text;
44
45         /**
46          * Creates a new reply shell.
47          */
48         public ReplyShell() {
49                 super(null, null, null);
50         }
51
52         //
53         // ACCESSORS
54         //
55
56         /**
57          * Returns the Sone that posted this reply.
58          *
59          * @return The Sone that posted this reply
60          */
61         @Override
62         public Sone getSone() {
63                 return sone;
64         }
65
66         /**
67          * Sets the Sone that posted this reply.
68          *
69          * @param sone
70          *            The sone that pasted this reply
71          * @return This reply shell (for method chaining)
72          */
73         public ReplyShell setSone(Sone sone) {
74                 this.sone = sone;
75                 return this;
76         }
77
78         /**
79          * Returns the ID of the reply.
80          *
81          * @return The ID of the reply
82          */
83         @Override
84         public String getId() {
85                 return id.toString();
86         }
87
88         /**
89          * Sets the ID of this reply.
90          *
91          * @param id
92          *            The ID of this reply
93          * @return This reply shell (for method chaining)
94          */
95         public ReplyShell setId(UUID id) {
96                 this.id = id;
97                 return this;
98         }
99
100         /**
101          * Returns the post this reply refers to.
102          *
103          * @return The post this reply refers to
104          */
105         @Override
106         public Post getPost() {
107                 return post;
108         }
109
110         /**
111          * Sets the post this reply refers to.
112          *
113          * @param post
114          *            The post this reply refers to
115          * @return This reply shell (for method chaining)
116          */
117         public ReplyShell setPost(Post post) {
118                 this.post = post;
119                 return this;
120         }
121
122         /**
123          * Returns the time of the reply.
124          *
125          * @return The time of the reply (in milliseconds since Jan 1, 1970 UTC)
126          */
127         @Override
128         public long getTime() {
129                 return time;
130         }
131
132         /**
133          * Sets the time of this reply.
134          *
135          * @param time
136          *            The time of this reply (in milliseconds since Jan 1, 1970 UTC)
137          * @return This reply shell (for method chaining)
138          */
139         public ReplyShell setTime(long time) {
140                 this.time = time;
141                 return this;
142         }
143
144         /**
145          * Returns the text of the reply.
146          *
147          * @return The text of the reply
148          */
149         @Override
150         public String getText() {
151                 return text;
152         }
153
154         /**
155          * Sets the text of the reply.
156          *
157          * @param text
158          *            The text of the reply
159          * @return This reply shell (for method chaining)
160          */
161         public ReplyShell setText(String text) {
162                 this.text = text;
163                 return this;
164         }
165
166         //
167         // INTERFACE Shell
168         //
169
170         /**
171          * {@inheritDoc}
172          */
173         @Override
174         public boolean canUnshell() {
175                 return (sone != null) && (id != null) && (post != null) && (time != null) && (text != null);
176         }
177
178         /**
179          * {@inheritDoc}
180          */
181         @Override
182         public Reply getShelled() {
183                 if (canUnshell()) {
184                         return new Reply(sone, id, post, time, text);
185                 }
186                 return null;
187         }
188
189 }