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