X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fdata%2Fimpl%2FAbstractAlbumBuilder.java;h=04b0eac6e321b2ba43faa23234628e8264a6c060;hp=312c79550b51f71204eb673d09f623e5663205c5;hb=faf66247a34f64946990a985d2ea3003465969cb;hpb=5960d429777d56130ce044e7f38406be0f44495b diff --git a/src/main/java/net/pterodactylus/sone/data/impl/AbstractAlbumBuilder.java b/src/main/java/net/pterodactylus/sone/data/impl/AbstractAlbumBuilder.java index 312c795..04b0eac 100644 --- a/src/main/java/net/pterodactylus/sone/data/impl/AbstractAlbumBuilder.java +++ b/src/main/java/net/pterodactylus/sone/data/impl/AbstractAlbumBuilder.java @@ -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 David ‘Bombe’ Roden */ 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"); } }