Move reply like functionality from Sone to Reply.
[Sone.git] / src / main / java / net / pterodactylus / sone / database / PostReplyDatabase.java
1 /*
2  * Sone - PostReplyDatabase.java - Copyright © 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.database;
19
20 import java.util.Collection;
21 import java.util.List;
22 import java.util.Set;
23
24 import net.pterodactylus.sone.data.PostReply;
25 import net.pterodactylus.sone.data.Sone;
26
27 import com.google.common.base.Optional;
28
29 /**
30  * Database for handling {@link PostReply}s.
31  *
32  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
33  */
34 public interface PostReplyDatabase {
35
36         /**
37          * Returns the reply with the given ID.
38          *
39          * @param id
40          *            The ID of the reply to get
41          * @return The reply, or {@code null} if there is no such reply
42          */
43         Optional<PostReply> getPostReply(String id);
44
45         /**
46          * Returns all replies for the given post, order ascending by time.
47          *
48          * @param postId
49          *            The ID of the post to get all replies for
50          * @return All replies for the given post
51          */
52         List<PostReply> getReplies(String postId);
53
54         boolean isPostReplyKnown(PostReply postReply);
55         void setPostReplyKnown(PostReply postReply);
56
57         /**
58          * Stores the given post reply.
59          *
60          * @param postReply
61          *            The post reply
62          */
63         void storePostReply(PostReply postReply);
64
65         /**
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!
68          *
69          * @param sone
70          *            The Sone to store all post replies for
71          * @param postReplies
72          *            The post replies of the Sone
73          * @throws IllegalArgumentException
74          *             if one of the replies does not belong to the given Sone
75          */
76         void storePostReplies(Sone sone, Collection<PostReply> postReplies) throws IllegalArgumentException;
77
78         /**
79          * Removes the given post reply from this store.
80          *
81          * @param postReply
82          *            The post reply to remove
83          */
84         void removePostReply(PostReply postReply);
85
86         /**
87          * Removes all post replies of the given Sone.
88          *
89          * @param sone
90          *            The Sone to remove all post replies for
91          */
92         void removePostReplies(Sone sone);
93
94         void likePostReply(PostReply postReply, Sone localSone);
95         void unlikePostReply(PostReply postReply, Sone localSone);
96
97         boolean isLiked(PostReply postReply, Sone sone);
98         Set<Sone> getLikes(PostReply postReply);
99
100 }