X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fdata%2Fimpl%2FAbstractSoneBuilder.java;h=a2f1333123ddcca6c743d3ac5b9d3aaf54c5a95f;hb=d15563b5b582b71366a52a361537c06cd52ae55b;hp=1ce38e4ed0c358384091f915b701217e04614186;hpb=3752ebf20fcb0c71287f2b7fed358b14c7649d7f;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/data/impl/AbstractSoneBuilder.java b/src/main/java/net/pterodactylus/sone/data/impl/AbstractSoneBuilder.java index 1ce38e4..a2f1333 100644 --- a/src/main/java/net/pterodactylus/sone/data/impl/AbstractSoneBuilder.java +++ b/src/main/java/net/pterodactylus/sone/data/impl/AbstractSoneBuilder.java @@ -2,7 +2,12 @@ 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.data.PostReply; import net.pterodactylus.sone.database.SoneBuilder; import net.pterodactylus.sone.freenet.wot.Identity; import net.pterodactylus.sone.freenet.wot.OwnIdentity; @@ -18,6 +23,8 @@ public abstract class AbstractSoneBuilder implements SoneBuilder { protected boolean local; protected long lastUpdated; protected Client client; + protected final Collection posts = new HashSet(); + protected final Collection postReplies = new HashSet(); @Override public SoneBuilder from(Identity identity) { @@ -43,6 +50,20 @@ public abstract class AbstractSoneBuilder implements SoneBuilder { return this; } + @Override + public SoneBuilder withPosts(Collection posts) { + this.posts.clear(); + this.posts.addAll(posts); + return this; + } + + @Override + public SoneBuilder withPostReplies(Collection postReplies) { + this.postReplies.clear(); + this.postReplies.addAll(postReplies); + return this; + } + protected void validate() throws IllegalStateException { checkState(identity != null, "identity must not be null"); checkState(!local || (identity instanceof OwnIdentity),