2 * Sone - Sone.java - Copyright © 2010–2020 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;
20 import java.util.Collection;
21 import java.util.List;
24 import javax.annotation.Nonnull;
25 import javax.annotation.Nullable;
27 import net.pterodactylus.sone.freenet.wot.Identity;
29 import freenet.keys.FreenetURI;
32 * A Sone defines everything about a user: her profile, her status updates, her
33 * replies, her likes and dislikes, etc.
35 public interface Sone extends Identified, Fingerprintable, Comparable<Sone> {
38 * Enumeration for the possible states of a {@link Sone}.
40 public enum SoneStatus {
42 /** The Sone is unknown, i.e. not yet downloaded. */
45 /** The Sone is idle, i.e. not being downloaded or inserted. */
48 /** The Sone is currently being inserted. */
51 /** The Sone is currently being downloaded. */
56 * Returns the identity of this Sone.
58 * @return The identity of this Sone
61 Identity getIdentity();
64 * Returns the name of this Sone.
66 * @return The name of this Sone
72 * Returns whether this Sone is a local Sone.
74 * @return {@code true} if this Sone is a local Sone, {@code false} otherwise
79 * Returns the request URI of this Sone.
81 * @return The request URI of this Sone
84 FreenetURI getRequestUri();
87 * Returns the latest edition of this Sone.
89 * @return The latest edition of this Sone
91 long getLatestEdition();
94 * Sets the latest edition of this Sone. If the given latest edition is not
95 * greater than the current latest edition, the latest edition of this Sone is
98 * @param latestEdition
99 * The latest edition of this Sone
101 void setLatestEdition(long latestEdition);
104 * Return the time of the last inserted update of this Sone.
106 * @return The time of the update (in milliseconds since Jan 1, 1970 UTC)
111 * Sets the time of the last inserted update of this Sone.
114 * The time of the update (in milliseconds since Jan 1, 1970 UTC)
115 * @return This Sone (for method chaining)
118 Sone setTime(long time);
121 * Returns the status of this Sone.
123 * @return The status of this Sone
126 SoneStatus getStatus();
129 * Sets the new status of this Sone.
132 * The new status of this Sone
134 * @throws IllegalArgumentException
135 * if {@code status} is {@code null}
138 Sone setStatus(@Nonnull SoneStatus status);
141 * Returns a copy of the profile. If you want to update values in the profile
142 * of this Sone, update the values in the returned {@link Profile} and use
143 * {@link #setProfile(Profile)} to change the profile in this Sone.
145 * @return A copy of the profile
148 Profile getProfile();
151 * Sets the profile of this Sone. A copy of the given profile is stored so that
152 * subsequent modifications of the given profile are not reflected in this
158 void setProfile(@Nonnull Profile profile);
161 * Returns the client used by this Sone.
163 * @return The client used by this Sone, or {@code null}
169 * Sets the client used by this Sone.
172 * The client used by this Sone, or {@code null}
173 * @return This Sone (for method chaining)
176 Sone setClient(@Nullable Client client);
179 * Returns whether this Sone is known.
181 * @return {@code true} if this Sone is known, {@code false} otherwise
186 * Sets whether this Sone is known.
189 * {@code true} if this Sone is known, {@code false} otherwise
193 Sone setKnown(boolean known);
196 * Returns all friend Sones of this Sone.
198 * @return The friend Sones of this Sone
201 Collection<String> getFriends();
204 * Returns whether this Sone has the given Sone as a friend Sone.
206 * @param friendSoneId
207 * The ID of the Sone to check for
208 * @return {@code true} if this Sone has the given Sone as a friend, {@code
211 boolean hasFriend(@Nonnull String friendSoneId);
214 * Returns the list of posts of this Sone, sorted by time, newest first.
216 * @return All posts of this Sone
219 List<Post> getPosts();
222 * Sets all posts of this Sone at once.
225 * The new (and only) posts of this Sone
226 * @return This Sone (for method chaining)
229 Sone setPosts(@Nonnull Collection<Post> posts);
232 * Adds the given post to this Sone. The post will not be added if its {@link
233 * Post#getSone() Sone} is not this Sone.
238 void addPost(@Nonnull Post post);
241 * Removes the given post from this Sone.
246 void removePost(@Nonnull Post post);
249 * Returns all replies this Sone made.
251 * @return All replies this Sone made
254 Set<PostReply> getReplies();
257 * Sets all replies of this Sone at once.
260 * The new (and only) replies of this Sone
261 * @return This Sone (for method chaining)
264 Sone setReplies(@Nonnull Collection<PostReply> replies);
267 * Adds a reply to this Sone. If the given reply was not made by this Sone,
268 * nothing is added to this Sone.
273 void addReply(@Nonnull PostReply reply);
276 * Removes a reply from this Sone.
279 * The reply to remove
281 void removeReply(@Nonnull PostReply reply);
284 * Returns the IDs of all liked posts.
286 * @return All liked posts’ IDs
289 Set<String> getLikedPostIds();
292 * Sets the IDs of all liked posts.
294 * @param likedPostIds
295 * All liked posts’ IDs
296 * @return This Sone (for method chaining)
299 Sone setLikePostIds(@Nonnull Set<String> likedPostIds);
302 * Checks whether the given post ID is liked by this Sone.
306 * @return {@code true} if this Sone likes the given post, {@code false}
309 boolean isLikedPostId(@Nonnull String postId);
312 * Adds the given post ID to the list of posts this Sone likes.
316 * @return This Sone (for method chaining)
319 Sone addLikedPostId(@Nonnull String postId);
322 * Removes the given post ID from the list of posts this Sone likes.
327 void removeLikedPostId(@Nonnull String postId);
330 * Returns the IDs of all liked replies.
332 * @return All liked replies’ IDs
335 Set<String> getLikedReplyIds();
338 * Sets the IDs of all liked replies.
340 * @param likedReplyIds
341 * All liked replies’ IDs
342 * @return This Sone (for method chaining)
345 Sone setLikeReplyIds(@Nonnull Set<String> likedReplyIds);
348 * Checks whether the given reply ID is liked by this Sone.
351 * The ID of the reply
352 * @return {@code true} if this Sone likes the given reply, {@code false}
355 boolean isLikedReplyId(@Nonnull String replyId);
358 * Adds the given reply ID to the list of replies this Sone likes.
361 * The ID of the reply
362 * @return This Sone (for method chaining)
365 Sone addLikedReplyId(@Nonnull String replyId);
368 * Removes the given post ID from the list of replies this Sone likes.
371 * The ID of the reply
373 void removeLikedReplyId(@Nonnull String replyId);
376 * Returns the root album that contains all visible albums of this Sone.
378 * @return The root album of this Sone
381 Album getRootAlbum();
384 * Returns Sone-specific options.
386 * @return The options of this Sone
389 SoneOptions getOptions();
392 * Sets the options of this Sone.
395 * The options of this Sone
397 /* TODO - remove this method again, maybe add an option provider */
398 void setOptions(@Nonnull SoneOptions options);