/*
- * Sone - AbstractAlbumBuilder.java - Copyright © 2013 David Roden
+ * Sone - AbstractAlbumBuilder.java - Copyright © 2013–2019 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
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 {
/** The ID of the album to create. */
protected String id;
+ protected Sone sone;
@Override
public AlbumBuilder randomId() {
return this;
}
+ public AlbumBuilder by(Sone sone) {
+ this.sone = sone;
+ return this;
+ }
+
//
// PROTECTED METHODS
//
*/
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");
}
}