Add callback interface to post build() method.
[Sone.git] / src / main / java / net / pterodactylus / sone / database / PostBuilder.java
index c46bd69..5564a93 100644 (file)
@@ -20,6 +20,8 @@ package net.pterodactylus.sone.database;
 import net.pterodactylus.sone.data.Post;
 import net.pterodactylus.sone.data.Sone;
 
+import com.google.common.base.Optional;
+
 /**
  * Builder for {@link Post} objects.
  * <p>
@@ -43,17 +45,6 @@ import net.pterodactylus.sone.data.Sone;
 public interface PostBuilder {
 
        /**
-        * Copies all attributes of the given post to this post builder.
-        *
-        * @param post
-        *            The post whose attributes to copy into this builder
-        * @return This builder
-        * @throws NullPointerException
-        *             if {@code post} is {@code null}
-        */
-       public PostBuilder copyPost(Post post) throws NullPointerException;
-
-       /**
         * Configures this builder to use a random ID for the new post. If this
         * method is used, {@link #withId(String)} must not be used.
         *
@@ -106,7 +97,7 @@ public interface PostBuilder {
         *            The ID of the recipient of the post
         * @return This post builder
         */
-       public PostBuilder to(String recipientId);
+       public PostBuilder to(Optional<String> recipientId);
 
        /**
         * Verifies this builder’s configuration and creates a new post.
@@ -130,6 +121,12 @@ public interface PostBuilder {
         * @throws IllegalStateException
         *             if this builder’s configuration is not valid
         */
-       public Post build() throws IllegalStateException;
+       public Post build(Optional<PostCreated> postCreated) throws IllegalStateException;
+
+       interface PostCreated {
+
+               void postCreated(Post post);
+
+       }
 
 }