Set client in Sone builder.
[Sone.git] / src / main / java / net / pterodactylus / sone / data / impl / AbstractSoneBuilder.java
index b7dda3f..1ce38e4 100644 (file)
@@ -2,6 +2,7 @@ package net.pterodactylus.sone.data.impl;
 
 import static com.google.common.base.Preconditions.checkState;
 
+import net.pterodactylus.sone.data.Client;
 import net.pterodactylus.sone.database.SoneBuilder;
 import net.pterodactylus.sone.freenet.wot.Identity;
 import net.pterodactylus.sone.freenet.wot.OwnIdentity;
@@ -16,6 +17,7 @@ public abstract class AbstractSoneBuilder implements SoneBuilder {
        protected Identity identity;
        protected boolean local;
        protected long lastUpdated;
+       protected Client client;
 
        @Override
        public SoneBuilder from(Identity identity) {
@@ -35,11 +37,18 @@ public abstract class AbstractSoneBuilder implements SoneBuilder {
                return this;
        }
 
+       @Override
+       public SoneBuilder using(Client client) {
+               this.client = client;
+               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");
        }
 
 }