Move PostReplyProvider and PostReplyStore into PostReplyDatabase.
[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         /**
54          * Stores the given post reply.
55          *
56          * @param postReply
57          *            The post reply
58          */
59         void storePostReply(PostReply postReply);
60
61         /**
62          * Stores the given post replies as exclusive collection of post replies for
63          * the given Sone. This will remove all other post replies from this Sone!
64          *
65          * @param sone
66          *            The Sone to store all post replies for
67          * @param postReplies
68          *            The post replies of the Sone
69          * @throws IllegalArgumentException
70          *             if one of the replies does not belong to the given Sone
71          */
72         void storePostReplies(Sone sone, Collection<PostReply> postReplies) throws IllegalArgumentException;
73
74         /**
75          * Removes the given post reply from this store.
76          *
77          * @param postReply
78          *            The post reply to remove
79          */
80         void removePostReply(PostReply postReply);
81
82         /**
83          * Removes all post replies of the given Sone.
84          *
85          * @param sone
86          *            The Sone to remove all post replies for
87          */
88         void removePostReplies(Sone sone);
89
90 }