Use Sone builder to set the posts of a Sone.
[Sone.git] / src / main / java / net / pterodactylus / sone / data / impl / AbstractSoneBuilder.java
index 1ce38e4..bc19d4d 100644 (file)
@@ -2,7 +2,11 @@ package net.pterodactylus.sone.data.impl;
 
 import static com.google.common.base.Preconditions.checkState;
 
+import java.util.Collection;
+import java.util.HashSet;
+
 import net.pterodactylus.sone.data.Client;
+import net.pterodactylus.sone.data.Post;
 import net.pterodactylus.sone.database.SoneBuilder;
 import net.pterodactylus.sone.freenet.wot.Identity;
 import net.pterodactylus.sone.freenet.wot.OwnIdentity;
@@ -18,6 +22,7 @@ public abstract class AbstractSoneBuilder implements SoneBuilder {
        protected boolean local;
        protected long lastUpdated;
        protected Client client;
+       protected final Collection<Post> posts = new HashSet<Post>();
 
        @Override
        public SoneBuilder from(Identity identity) {
@@ -43,6 +48,13 @@ public abstract class AbstractSoneBuilder implements SoneBuilder {
                return this;
        }
 
+       @Override
+       public SoneBuilder withPosts(Collection<Post> posts) {
+               this.posts.clear();
+               this.posts.addAll(posts);
+               return this;
+       }
+
        protected void validate() throws IllegalStateException {
                checkState(identity != null, "identity must not be null");
                checkState(!local || (identity instanceof OwnIdentity),