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=35b87e8131cd37e080a7fa545998051e44eb35f1;hpb=015c9b8f78af4f1dbcaa97ec3cb77e3c4cb09c84;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 35b87e8..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.data.Post;
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,18 +34,25 @@ import org.apache.commons.lang.StringUtils;
*
* @author David âBombeâ Roden
*/
-public class PostReplyBuilderImpl extends AbstractReplyBuilder implements PostReplyBuilder {
+public class PostReplyBuilderImpl extends AbstractPostReplyBuilder {
- /** The post the created reply refers to. */
- private Post post;
+ /** The Sone provider. */
+ private final SoneProvider soneProvider;
+
+ /** The post provider. */
+ private final PostProvider postProvider;
/**
- * {@inheritDoc}
+ * Creates a new post reply builder.
+ *
+ * @param soneProvider
+ * The Sone provider
+ * @param postProvider
+ * The post provider
*/
- @Override
- public PostReplyBuilder to(Post post) {
- this.post = post;
- return this;
+ public PostReplyBuilderImpl(SoneProvider soneProvider, PostProvider postProvider) {
+ this.soneProvider = soneProvider;
+ this.postProvider = postProvider;
}
/**
@@ -53,17 +61,13 @@ public class PostReplyBuilderImpl extends AbstractReplyBuilder
@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(post != null, "post must not be null");
+ checkState(postId != null, "post must not be null");
/* create new post reply. */
- PostReplyImpl postReplyImpl = new PostReplyImpl(randomId ? UUID.randomUUID().toString() : id);
- postReplyImpl.setSone(sender);
- postReplyImpl.setPost(post);
- 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);
}
+
}