X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fdatabase%2FPostReplyDatabase.java;h=5bcbf29bc4755f22b1f83452242cbeec447101ca;hb=c4eb31ab64627adfdeed2a445d67883371203e99;hp=c9a809fbab80e5eb34140ea62189cd130a26f1b0;hpb=6e9a43ccd93ae125720547c0fe421dc81a54ba90;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/database/PostReplyDatabase.java b/src/main/java/net/pterodactylus/sone/database/PostReplyDatabase.java index c9a809f..5bcbf29 100644 --- a/src/main/java/net/pterodactylus/sone/database/PostReplyDatabase.java +++ b/src/main/java/net/pterodactylus/sone/database/PostReplyDatabase.java @@ -17,14 +17,84 @@ package net.pterodactylus.sone.database; +import java.util.Collection; +import java.util.List; +import java.util.Set; + +import net.pterodactylus.sone.data.PostReply; +import net.pterodactylus.sone.data.Sone; + +import com.google.common.base.Optional; + /** - * Combines a {@link PostReplyProvider}, a {@link PostReplyBuilderFactory}, and - * a {@link PostReplyStore} into a complete post reply database. + * Database for handling {@link PostReply}s. * * @author David ‘Bombe’ Roden */ -public interface PostReplyDatabase extends PostReplyProvider, PostReplyBuilderFactory, PostReplyStore { +public interface PostReplyDatabase { + + /** + * Returns the reply with the given ID. + * + * @param id + * The ID of the reply to get + * @return The reply, or {@code null} if there is no such reply + */ + Optional getPostReply(String id); + + /** + * Returns all replies for the given post, order ascending by time. + * + * @param postId + * The ID of the post to get all replies for + * @return All replies for the given post + */ + List getReplies(String postId); + + boolean isPostReplyKnown(PostReply postReply); + void setPostReplyKnown(PostReply postReply); + + /** + * Stores the given post reply. + * + * @param postReply + * The post reply + */ + void storePostReply(PostReply postReply); + + /** + * Stores the given post replies as exclusive collection of post replies for + * the given Sone. This will remove all other post replies from this Sone! + * + * @param sone + * The Sone to store all post replies for + * @param postReplies + * The post replies of the Sone + * @throws IllegalArgumentException + * if one of the replies does not belong to the given Sone + */ + void storePostReplies(Sone sone, Collection postReplies) throws IllegalArgumentException; + + /** + * Removes the given post reply from this store. + * + * @param postReply + * The post reply to remove + */ + void removePostReply(PostReply postReply); + + /** + * Removes all post replies of the given Sone. + * + * @param sone + * The Sone to remove all post replies for + */ + void removePostReplies(Sone sone); + + void likePostReply(PostReply postReply, Sone localSone); + void unlikePostReply(PostReply postReply, Sone localSone); - /* nothing here. */ + boolean isLiked(PostReply postReply, Sone sone); + Set getLikes(PostReply postReply); }