X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fdata%2Fimpl%2FPostReplyBuilderImpl.java;h=dac84addaf62186ff388b76337a6d8d3f576fdd8;hb=7df20dec7dcc9aa6d1aa657d24f273e1a82c60fc;hp=18ce2005f321fcb4da587ca219fdf423c6fc4e0a;hpb=fcabe38e9b3abacc0d580bf0513600858aee2eca;p=Sone.git
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 18ce200..dac84ad 100644
--- a/src/main/java/net/pterodactylus/sone/data/impl/PostReplyBuilderImpl.java
+++ b/src/main/java/net/pterodactylus/sone/data/impl/PostReplyBuilderImpl.java
@@ -21,9 +21,10 @@ import static com.google.common.base.Preconditions.checkState;
import java.util.UUID;
-import net.pterodactylus.sone.core.PostProvider;
import net.pterodactylus.sone.data.PostReply;
-import net.pterodactylus.sone.data.PostReplyBuilder;
+import net.pterodactylus.sone.database.PostProvider;
+import net.pterodactylus.sone.database.PostReplyBuilder;
+import net.pterodactylus.sone.database.SoneProvider;
import org.apache.commons.lang.StringUtils;
@@ -33,21 +34,24 @@ import org.apache.commons.lang.StringUtils;
*
* @author David âBombeâ Roden
*/
-public class PostReplyBuilderImpl extends AbstractReplyBuilder implements PostReplyBuilder {
+public class PostReplyBuilderImpl extends AbstractPostReplyBuilder {
- /** The post builder. */
- private final PostProvider postProvider;
+ /** The Sone provider. */
+ private final SoneProvider soneProvider;
- /** The ID of the post the created reply refers to. */
- private String postId;
+ /** The post provider. */
+ private final PostProvider postProvider;
/**
* Creates a new post reply builder.
*
+ * @param soneProvider
+ * The Sone provider
* @param postProvider
* The post provider
*/
- public PostReplyBuilderImpl(PostProvider postProvider) {
+ public PostReplyBuilderImpl(SoneProvider soneProvider, PostProvider postProvider) {
+ this.soneProvider = soneProvider;
this.postProvider = postProvider;
}
@@ -55,28 +59,15 @@ public class PostReplyBuilderImpl extends AbstractReplyBuilder
* {@inheritDoc}
*/
@Override
- public PostReplyBuilder to(String postId) {
- this.postId = postId;
- return this;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
public PostReply build() {
checkState((randomId && (id == null)) || (!randomId && (id != null)), "either random ID nor custom ID must be set");
- checkState(sender != null, "sender must not be null");
+ checkState(senderId != null, "sender must not be null");
checkState((currentTime && (time == 0)) || (!currentTime && (time >= 0)), "either current time or custom time must be set");
checkState(!StringUtils.isBlank(text), "text must not be empty");
checkState(postId != null, "post must not be null");
/* create new post reply. */
- PostReplyImpl postReplyImpl = new PostReplyImpl(postProvider, randomId ? UUID.randomUUID().toString() : id);
- postReplyImpl.setSone(sender);
- postReplyImpl.setPost(postId);
- postReplyImpl.setTime(currentTime ? System.currentTimeMillis() : time);
- postReplyImpl.setText(text);
- return postReplyImpl;
+ return new PostReplyImpl(soneProvider, postProvider, randomId ? UUID.randomUUID().toString() : id, senderId, currentTime ? System.currentTimeMillis() : time, text, postId);
}
+
}