From: David ‘Bombe’ Roden Date: Tue, 22 Jan 2013 14:38:22 +0000 (+0100) Subject: Move provider interfaces to database package. X-Git-Tag: 0.8.5^2~3^2~45^2~1 X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=commitdiff_plain;h=658a702c550e15bd3c868ed399621606eeb4ef20 Move provider interfaces to database package. --- diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index bafe7a8..7f62685 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -67,6 +67,9 @@ import net.pterodactylus.sone.data.Reply; import net.pterodactylus.sone.data.Sone; import net.pterodactylus.sone.data.Sone.ShowCustomAvatars; import net.pterodactylus.sone.data.Sone.SoneStatus; +import net.pterodactylus.sone.database.PostProvider; +import net.pterodactylus.sone.database.PostReplyProvider; +import net.pterodactylus.sone.database.SoneProvider; import net.pterodactylus.sone.data.TemporaryImage; import net.pterodactylus.sone.fcp.FcpInterface; import net.pterodactylus.sone.fcp.FcpInterface.FullAccessRequired; diff --git a/src/main/java/net/pterodactylus/sone/core/PostProvider.java b/src/main/java/net/pterodactylus/sone/core/PostProvider.java deleted file mode 100644 index d97a7ce..0000000 --- a/src/main/java/net/pterodactylus/sone/core/PostProvider.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Sone - PostProvider.java - Copyright © 2011–2013 David Roden - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.pterodactylus.sone.core; - -import java.util.Collection; - -import net.pterodactylus.sone.data.Post; - -/** - * Interface for objects that can provide {@link Post}s by their ID. - * - * @author David ‘Bombe’ Roden - */ -public interface PostProvider { - - /** - * Returns the post with the given ID. - * - * @param postId - * The ID of the post to return - * @return The post with the given ID, or {@code null} - */ - public Post getPost(String postId); - - /** - * Returns all posts that have the given Sone as recipient. - * - * @see Post#getRecipient() - * @param recipientId - * The ID of the recipient of the posts - * @return All posts that have the given Sone as recipient - */ - public Collection getDirectedPosts(String recipientId); - -} diff --git a/src/main/java/net/pterodactylus/sone/core/PostReplyProvider.java b/src/main/java/net/pterodactylus/sone/core/PostReplyProvider.java deleted file mode 100644 index 9854b6c..0000000 --- a/src/main/java/net/pterodactylus/sone/core/PostReplyProvider.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Sone - PostReplyProvider.java - Copyright © 2013 David Roden - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.pterodactylus.sone.core; - -import java.util.List; - -import net.pterodactylus.sone.data.Post; -import net.pterodactylus.sone.data.PostReply; - -/** - * Interface for objects that can provide {@link PostReply}s. - * - * @author David ‘Bombe’ Roden - */ -public interface PostReplyProvider { - - /** - * 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 - */ - public PostReply getPostReply(String id); - - /** - * Returns all replies for the given post, order ascending by time. - * - * @param post - * The post to get all replies for - * @return All replies for the given post - */ - public List getReplies(Post post); - -} diff --git a/src/main/java/net/pterodactylus/sone/core/SoneProvider.java b/src/main/java/net/pterodactylus/sone/core/SoneProvider.java deleted file mode 100644 index 6b479df..0000000 --- a/src/main/java/net/pterodactylus/sone/core/SoneProvider.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Sone - SoneProvider.java - Copyright © 2011–2013 David Roden - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.pterodactylus.sone.core; - -import net.pterodactylus.sone.data.Sone; - -/** - * Interface for objects that can provide {@link Sone}s by their ID. - * - * @author David ‘Bombe’ Roden - */ -public interface SoneProvider { - - /** - * Returns the Sone with the given ID, if it exists. - * - * @param soneId - * The ID of the Sone to return - * @return The Sone with the given ID, or {@code null} - */ - public Sone getSone(String soneId); - -} diff --git a/src/main/java/net/pterodactylus/sone/data/impl/DefaultPostBuilderFactory.java b/src/main/java/net/pterodactylus/sone/data/impl/DefaultPostBuilderFactory.java index 25f6a86..fd17ec3 100644 --- a/src/main/java/net/pterodactylus/sone/data/impl/DefaultPostBuilderFactory.java +++ b/src/main/java/net/pterodactylus/sone/data/impl/DefaultPostBuilderFactory.java @@ -17,9 +17,9 @@ package net.pterodactylus.sone.data.impl; -import net.pterodactylus.sone.core.SoneProvider; import net.pterodactylus.sone.data.PostBuilder; import net.pterodactylus.sone.data.PostBuilderFactory; +import net.pterodactylus.sone.database.SoneProvider; /** * {@link PostBuilderFactory} implementation that creates diff --git a/src/main/java/net/pterodactylus/sone/data/impl/DefaultPostReplyBuilderFactory.java b/src/main/java/net/pterodactylus/sone/data/impl/DefaultPostReplyBuilderFactory.java index 5005e5e..1b8bab2 100644 --- a/src/main/java/net/pterodactylus/sone/data/impl/DefaultPostReplyBuilderFactory.java +++ b/src/main/java/net/pterodactylus/sone/data/impl/DefaultPostReplyBuilderFactory.java @@ -17,10 +17,10 @@ package net.pterodactylus.sone.data.impl; -import net.pterodactylus.sone.core.PostProvider; -import net.pterodactylus.sone.core.SoneProvider; import net.pterodactylus.sone.data.PostReplyBuilder; import net.pterodactylus.sone.data.PostReplyBuilderFactory; +import net.pterodactylus.sone.database.PostProvider; +import net.pterodactylus.sone.database.SoneProvider; import com.google.inject.Inject; diff --git a/src/main/java/net/pterodactylus/sone/data/impl/PostBuilderImpl.java b/src/main/java/net/pterodactylus/sone/data/impl/PostBuilderImpl.java index 929f315..32f4eb4 100644 --- a/src/main/java/net/pterodactylus/sone/data/impl/PostBuilderImpl.java +++ b/src/main/java/net/pterodactylus/sone/data/impl/PostBuilderImpl.java @@ -21,9 +21,9 @@ import static com.google.common.base.Preconditions.checkState; import java.util.UUID; -import net.pterodactylus.sone.core.SoneProvider; import net.pterodactylus.sone.data.Post; import net.pterodactylus.sone.data.PostBuilder; +import net.pterodactylus.sone.database.SoneProvider; import org.apache.commons.lang.StringUtils; diff --git a/src/main/java/net/pterodactylus/sone/data/impl/PostImpl.java b/src/main/java/net/pterodactylus/sone/data/impl/PostImpl.java index d422cba..d008463 100644 --- a/src/main/java/net/pterodactylus/sone/data/impl/PostImpl.java +++ b/src/main/java/net/pterodactylus/sone/data/impl/PostImpl.java @@ -19,9 +19,9 @@ package net.pterodactylus.sone.data.impl; import java.util.UUID; -import net.pterodactylus.sone.core.SoneProvider; import net.pterodactylus.sone.data.Post; import net.pterodactylus.sone.data.Sone; +import net.pterodactylus.sone.database.SoneProvider; /** * A post is a short message that a user writes in his Sone to let other users diff --git a/src/main/java/net/pterodactylus/sone/data/impl/PostReplyBuilderImpl.java b/src/main/java/net/pterodactylus/sone/data/impl/PostReplyBuilderImpl.java index 1709b6e..c553bc3 100644 --- a/src/main/java/net/pterodactylus/sone/data/impl/PostReplyBuilderImpl.java +++ b/src/main/java/net/pterodactylus/sone/data/impl/PostReplyBuilderImpl.java @@ -21,10 +21,10 @@ import static com.google.common.base.Preconditions.checkState; import java.util.UUID; -import net.pterodactylus.sone.core.PostProvider; -import net.pterodactylus.sone.core.SoneProvider; import net.pterodactylus.sone.data.PostReply; import net.pterodactylus.sone.data.PostReplyBuilder; +import net.pterodactylus.sone.database.PostProvider; +import net.pterodactylus.sone.database.SoneProvider; import org.apache.commons.lang.StringUtils; diff --git a/src/main/java/net/pterodactylus/sone/data/impl/PostReplyImpl.java b/src/main/java/net/pterodactylus/sone/data/impl/PostReplyImpl.java index 97c84e4..87c792a 100644 --- a/src/main/java/net/pterodactylus/sone/data/impl/PostReplyImpl.java +++ b/src/main/java/net/pterodactylus/sone/data/impl/PostReplyImpl.java @@ -17,10 +17,10 @@ package net.pterodactylus.sone.data.impl; -import net.pterodactylus.sone.core.PostProvider; -import net.pterodactylus.sone.core.SoneProvider; import net.pterodactylus.sone.data.Post; import net.pterodactylus.sone.data.PostReply; +import net.pterodactylus.sone.database.PostProvider; +import net.pterodactylus.sone.database.SoneProvider; /** * Simple {@link PostReply} implementation. diff --git a/src/main/java/net/pterodactylus/sone/data/impl/ReplyImpl.java b/src/main/java/net/pterodactylus/sone/data/impl/ReplyImpl.java index 5ede070..5f7dac0 100644 --- a/src/main/java/net/pterodactylus/sone/data/impl/ReplyImpl.java +++ b/src/main/java/net/pterodactylus/sone/data/impl/ReplyImpl.java @@ -17,9 +17,9 @@ package net.pterodactylus.sone.data.impl; -import net.pterodactylus.sone.core.SoneProvider; import net.pterodactylus.sone.data.Reply; import net.pterodactylus.sone.data.Sone; +import net.pterodactylus.sone.database.SoneProvider; /** * Abstract base class for all replies. diff --git a/src/main/java/net/pterodactylus/sone/database/PostProvider.java b/src/main/java/net/pterodactylus/sone/database/PostProvider.java new file mode 100644 index 0000000..865376b --- /dev/null +++ b/src/main/java/net/pterodactylus/sone/database/PostProvider.java @@ -0,0 +1,50 @@ +/* + * Sone - PostProvider.java - Copyright © 2011–2013 David Roden + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.pterodactylus.sone.database; + +import java.util.Collection; + +import net.pterodactylus.sone.data.Post; + +/** + * Interface for objects that can provide {@link Post}s by their ID. + * + * @author David ‘Bombe’ Roden + */ +public interface PostProvider { + + /** + * Returns the post with the given ID. + * + * @param postId + * The ID of the post to return + * @return The post with the given ID, or {@code null} + */ + public Post getPost(String postId); + + /** + * Returns all posts that have the given Sone as recipient. + * + * @see Post#getRecipient() + * @param recipientId + * The ID of the recipient of the posts + * @return All posts that have the given Sone as recipient + */ + public Collection getDirectedPosts(String recipientId); + +} diff --git a/src/main/java/net/pterodactylus/sone/database/PostReplyProvider.java b/src/main/java/net/pterodactylus/sone/database/PostReplyProvider.java new file mode 100644 index 0000000..2ad38a6 --- /dev/null +++ b/src/main/java/net/pterodactylus/sone/database/PostReplyProvider.java @@ -0,0 +1,50 @@ +/* + * Sone - PostReplyProvider.java - Copyright © 2013 David Roden + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.pterodactylus.sone.database; + +import java.util.List; + +import net.pterodactylus.sone.data.Post; +import net.pterodactylus.sone.data.PostReply; + +/** + * Interface for objects that can provide {@link PostReply}s. + * + * @author David ‘Bombe’ Roden + */ +public interface PostReplyProvider { + + /** + * 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 + */ + public PostReply getPostReply(String id); + + /** + * Returns all replies for the given post, order ascending by time. + * + * @param post + * The post to get all replies for + * @return All replies for the given post + */ + public List getReplies(Post post); + +} diff --git a/src/main/java/net/pterodactylus/sone/database/SoneProvider.java b/src/main/java/net/pterodactylus/sone/database/SoneProvider.java new file mode 100644 index 0000000..b1b1eb4 --- /dev/null +++ b/src/main/java/net/pterodactylus/sone/database/SoneProvider.java @@ -0,0 +1,38 @@ +/* + * Sone - SoneProvider.java - Copyright © 2011–2013 David Roden + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.pterodactylus.sone.database; + +import net.pterodactylus.sone.data.Sone; + +/** + * Interface for objects that can provide {@link Sone}s by their ID. + * + * @author David ‘Bombe’ Roden + */ +public interface SoneProvider { + + /** + * Returns the Sone with the given ID, if it exists. + * + * @param soneId + * The ID of the Sone to return + * @return The Sone with the given ID, or {@code null} + */ + public Sone getSone(String soneId); + +} diff --git a/src/main/java/net/pterodactylus/sone/main/SonePlugin.java b/src/main/java/net/pterodactylus/sone/main/SonePlugin.java index 04b0de4..36e49d1 100644 --- a/src/main/java/net/pterodactylus/sone/main/SonePlugin.java +++ b/src/main/java/net/pterodactylus/sone/main/SonePlugin.java @@ -24,13 +24,13 @@ import java.util.logging.Logger; import net.pterodactylus.sone.core.Core; import net.pterodactylus.sone.core.FreenetInterface; -import net.pterodactylus.sone.core.PostProvider; -import net.pterodactylus.sone.core.SoneProvider; import net.pterodactylus.sone.core.WebOfTrustUpdater; import net.pterodactylus.sone.data.PostBuilderFactory; import net.pterodactylus.sone.data.PostReplyBuilderFactory; import net.pterodactylus.sone.data.impl.DefaultPostBuilderFactory; import net.pterodactylus.sone.data.impl.DefaultPostReplyBuilderFactory; +import net.pterodactylus.sone.database.PostProvider; +import net.pterodactylus.sone.database.SoneProvider; import net.pterodactylus.sone.fcp.FcpInterface; import net.pterodactylus.sone.freenet.PluginStoreConfigurationBackend; import net.pterodactylus.sone.freenet.plugin.PluginConnector; diff --git a/src/main/java/net/pterodactylus/sone/text/SoneTextParser.java b/src/main/java/net/pterodactylus/sone/text/SoneTextParser.java index 8e3c023..9aacff6 100644 --- a/src/main/java/net/pterodactylus/sone/text/SoneTextParser.java +++ b/src/main/java/net/pterodactylus/sone/text/SoneTextParser.java @@ -26,10 +26,10 @@ import java.util.logging.Logger; import java.util.regex.Matcher; import java.util.regex.Pattern; -import net.pterodactylus.sone.core.PostProvider; -import net.pterodactylus.sone.core.SoneProvider; import net.pterodactylus.sone.data.Post; import net.pterodactylus.sone.data.Sone; +import net.pterodactylus.sone.database.PostProvider; +import net.pterodactylus.sone.database.SoneProvider; import net.pterodactylus.util.io.Closer; import net.pterodactylus.util.logging.Logging; import freenet.keys.FreenetURI; diff --git a/src/test/java/net/pterodactylus/sone/text/SoneTextParserTest.java b/src/test/java/net/pterodactylus/sone/text/SoneTextParserTest.java index 53c52dd..76f3755 100644 --- a/src/test/java/net/pterodactylus/sone/text/SoneTextParserTest.java +++ b/src/test/java/net/pterodactylus/sone/text/SoneTextParserTest.java @@ -22,8 +22,8 @@ import java.io.StringReader; import java.util.Arrays; import junit.framework.TestCase; -import net.pterodactylus.sone.core.SoneProvider; import net.pterodactylus.sone.data.Sone; +import net.pterodactylus.sone.database.SoneProvider; /** * JUnit test case for {@link SoneTextParser}.