Remove @author tags
[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.database.SoneBuilder;
6 import net.pterodactylus.sone.freenet.wot.Identity;
7 import net.pterodactylus.sone.freenet.wot.OwnIdentity;
8
9 /**
10  * Abstract {@link SoneBuilder} implementation.
11  */
12 public abstract class AbstractSoneBuilder implements SoneBuilder {
13
14         protected Identity identity;
15         protected boolean local;
16
17         @Override
18         public SoneBuilder from(Identity identity) {
19                 this.identity = identity;
20                 return this;
21         }
22
23         @Override
24         public SoneBuilder local() {
25                 this.local = true;
26                 return this;
27         }
28
29         protected void validate() throws IllegalStateException {
30                 checkState(identity != null, "identity must not be null");
31                 checkState(!local || (identity instanceof OwnIdentity),
32                                 "can not create local Sone from remote identity");
33         }
34
35 }