Set client information in Sone builder.
[Sone.git] / src / main / java / net / pterodactylus / sone / data / impl / AbstractSoneBuilder.java
1 package net.pterodactylus.sone.data.impl;
2
3 import static com.google.common.base.Preconditions.checkState;
4
5 import net.pterodactylus.sone.data.Client;
6 import net.pterodactylus.sone.database.SoneBuilder;
7 import net.pterodactylus.sone.freenet.wot.Identity;
8
9 import com.google.common.base.Preconditions;
10 import com.google.inject.internal.util.$Preconditions;
11
12 /**
13  * Abstract {@link SoneBuilder} implementation.
14  *
15  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
16  */
17 public abstract class AbstractSoneBuilder implements SoneBuilder {
18
19         protected String id;
20         protected boolean local;
21         protected Client client;
22
23         @Override
24         public SoneBuilder by(String id) {
25                 this.id = id;
26                 return this;
27         }
28
29         @Override
30         public SoneBuilder local() {
31                 local = true;
32                 return this;
33         }
34
35         @Override
36         public SoneBuilder using(Client client) {
37                 this.client = client;
38                 return this;
39         }
40
41         protected void validate() throws IllegalStateException {
42                 checkState(id != null, "id must not be null");
43                 checkState(client != null, "client must not be null");
44         }
45
46 }