2 * Sone - PostReplyDatabase.java - Copyright © 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.database;
20 import java.util.Collection;
21 import java.util.List;
24 import net.pterodactylus.sone.data.PostReply;
25 import net.pterodactylus.sone.data.Sone;
27 import com.google.common.base.Optional;
30 * Database for handling {@link PostReply}s.
32 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
34 public interface PostReplyDatabase {
37 * Returns the reply with the given ID.
40 * The ID of the reply to get
41 * @return The reply, or {@code null} if there is no such reply
43 Optional<PostReply> getPostReply(String id);
46 * Returns all replies for the given post, order ascending by time.
49 * The ID of the post to get all replies for
50 * @return All replies for the given post
52 List<PostReply> getReplies(String postId);
54 boolean isPostReplyKnown(PostReply postReply);
55 void setPostReplyKnown(PostReply postReply);
58 * Stores the given post reply.
63 void storePostReply(PostReply postReply);
66 * Stores the given post replies as exclusive collection of post replies for
67 * the given Sone. This will remove all other post replies from this Sone!
70 * The Sone to store all post replies for
72 * The post replies of the Sone
73 * @throws IllegalArgumentException
74 * if one of the replies does not belong to the given Sone
76 void storePostReplies(Sone sone, Collection<PostReply> postReplies) throws IllegalArgumentException;
79 * Removes the given post reply from this store.
82 * The post reply to remove
84 void removePostReply(PostReply postReply);
87 * Removes all post replies of the given Sone.
90 * The Sone to remove all post replies for
92 void removePostReplies(Sone sone);
94 void likePostReply(PostReply postReply, Sone localSone);
95 void unlikePostReply(PostReply postReply, Sone localSone);
97 boolean isLiked(PostReply postReply, Sone sone);
98 Set<Sone> getLikes(PostReply postReply);