X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fdata%2Fimpl%2FAbstractSoneBuilder.java;h=bc19d4d3c4c1394e70a8f97d897200f6b017853a;hb=90d193f69c4aa12c232f937a9d2b7d5afdda81dd;hp=a214677f3acbf7041090f9cb5a79832498caba64;hpb=210684b4bc499e298a0d0abeddd4008cdeb406bc;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 a214677..bc19d4d 100644 --- a/src/main/java/net/pterodactylus/sone/data/impl/AbstractSoneBuilder.java +++ b/src/main/java/net/pterodactylus/sone/data/impl/AbstractSoneBuilder.java @@ -2,6 +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; @@ -15,6 +20,9 @@ public abstract class AbstractSoneBuilder implements SoneBuilder { protected Identity identity; protected boolean local; + protected long lastUpdated; + protected Client client; + protected final Collection posts = new HashSet(); @Override public SoneBuilder from(Identity identity) { @@ -28,10 +36,31 @@ public abstract class AbstractSoneBuilder implements SoneBuilder { return this; } + @Override + public SoneBuilder lastUpdated(long lastUpdated) { + this.lastUpdated = lastUpdated; + return this; + } + + @Override + public SoneBuilder using(Client client) { + this.client = client; + return this; + } + + @Override + public SoneBuilder withPosts(Collection 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), "can not create local Sone from remote identity"); + checkState(lastUpdated > 0, "last update time must be set"); + checkState(client != null, "client must not be null"); } }