Make the update time of a Sone final, set it in the Sone builder.
[Sone.git] / src / main / java / net / pterodactylus / sone / data / impl / AbstractSoneBuilder.java
index a214677..b7dda3f 100644 (file)
@@ -15,6 +15,7 @@ public abstract class AbstractSoneBuilder implements SoneBuilder {
 
        protected Identity identity;
        protected boolean local;
+       protected long lastUpdated;
 
        @Override
        public SoneBuilder from(Identity identity) {
@@ -28,10 +29,17 @@ public abstract class AbstractSoneBuilder implements SoneBuilder {
                return this;
        }
 
+       @Override
+       public SoneBuilder lastUpdated(long lastUpdated) {
+               this.lastUpdated = lastUpdated;
+               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");
        }
 
 }