🔀 Merge “release/v81” into “master”
[Sone.git] / src / main / java / net / pterodactylus / sone / data / impl / AbstractAlbumBuilder.java
index 312c795..04b0eac 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Sone - AbstractAlbumBuilder.java - Copyright © 2013 David Roden
+ * Sone - AbstractAlbumBuilder.java - Copyright © 2013–2020 David Roden
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -19,13 +19,12 @@ package net.pterodactylus.sone.data.impl;
 
 import static com.google.common.base.Preconditions.checkState;
 
+import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.database.AlbumBuilder;
 
 /**
  * Abstract {@link AlbumBuilder} implementation. It stores the state of the new
  * album and performs validation, you only need to implement {@link #build()}.
- *
- * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
  */
 public abstract class AbstractAlbumBuilder implements AlbumBuilder {
 
@@ -34,6 +33,7 @@ public abstract class AbstractAlbumBuilder implements AlbumBuilder {
 
        /** The ID of the album to create. */
        protected String id;
+       protected Sone sone;
 
        @Override
        public AlbumBuilder randomId() {
@@ -47,6 +47,11 @@ public abstract class AbstractAlbumBuilder implements AlbumBuilder {
                return this;
        }
 
+       public AlbumBuilder by(Sone sone) {
+               this.sone = sone;
+               return this;
+       }
+
        //
        // PROTECTED METHODS
        //
@@ -59,6 +64,7 @@ public abstract class AbstractAlbumBuilder implements AlbumBuilder {
         */
        protected void validate() throws IllegalStateException {
                checkState((randomId && (id == null)) || (!randomId && (id != null)), "exactly one of random ID or custom ID must be set");
+               checkState(sone != null, "Sone must not be null");
        }
 
 }