1 package net.pterodactylus.sone.data.impl;
3 import static com.google.common.base.Preconditions.checkState;
5 import net.pterodactylus.sone.data.Client;
6 import net.pterodactylus.sone.database.SoneBuilder;
7 import net.pterodactylus.sone.freenet.wot.Identity;
8 import net.pterodactylus.sone.freenet.wot.OwnIdentity;
11 * Abstract {@link SoneBuilder} implementation.
13 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
15 public abstract class AbstractSoneBuilder implements SoneBuilder {
17 protected Identity identity;
18 protected boolean local;
19 protected long lastUpdated;
20 protected Client client;
23 public SoneBuilder from(Identity identity) {
24 this.identity = identity;
29 public SoneBuilder local() {
35 public SoneBuilder lastUpdated(long lastUpdated) {
36 this.lastUpdated = lastUpdated;
41 public SoneBuilder using(Client client) {
46 protected void validate() throws IllegalStateException {
47 checkState(identity != null, "identity must not be null");
48 checkState(!local || (identity instanceof OwnIdentity),
49 "can not create local Sone from remote identity");
50 checkState(lastUpdated > 0, "last update time must be set");
51 checkState(client != null, "client must not be null");