From c9aced5684dcd48b8b0696fcbc33463c3d62ec5e Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Tue, 15 Oct 2013 22:14:34 +0200 Subject: [PATCH] Remove AlbumBuilderFactory interface. --- .../java/net/pterodactylus/sone/data/Album.java | 6 ++-- .../java/net/pterodactylus/sone/data/Sone.java | 6 ++-- .../sone/database/AlbumBuilderFactory.java | 34 ---------------------- .../pterodactylus/sone/web/CreateAlbumPage.java | 6 ++-- 4 files changed, 11 insertions(+), 41 deletions(-) delete mode 100644 src/main/java/net/pterodactylus/sone/database/AlbumBuilderFactory.java diff --git a/src/main/java/net/pterodactylus/sone/data/Album.java b/src/main/java/net/pterodactylus/sone/data/Album.java index 7b245f9..a173e19 100644 --- a/src/main/java/net/pterodactylus/sone/data/Album.java +++ b/src/main/java/net/pterodactylus/sone/data/Album.java @@ -26,7 +26,7 @@ import java.util.Comparator; import java.util.List; import javax.annotation.Nonnull; -import net.pterodactylus.sone.database.AlbumBuilderFactory; +import net.pterodactylus.sone.database.AlbumBuilder; import net.pterodactylus.sone.database.ImageBuilder; import com.google.common.base.Function; @@ -40,7 +40,7 @@ import com.google.common.collect.ImmutableList; * * @author David ‘Bombe’ Roden */ -public interface Album extends Identified, Fingerprintable, AlbumBuilderFactory { +public interface Album extends Identified, Fingerprintable { /** Compares two {@link Album}s by {@link #getTitle()}. */ Comparator TITLE_COMPARATOR = new Comparator() { @@ -167,6 +167,8 @@ public interface Album extends Identified, Fingerprintable, AlbumBuilderFactory */ String getDescription(); + AlbumBuilder newAlbumBuilder() throws IllegalStateException; + ImageBuilder newImageBuilder() throws IllegalStateException; /** diff --git a/src/main/java/net/pterodactylus/sone/data/Sone.java b/src/main/java/net/pterodactylus/sone/data/Sone.java index 41fdcc1..f1d9ffe 100644 --- a/src/main/java/net/pterodactylus/sone/data/Sone.java +++ b/src/main/java/net/pterodactylus/sone/data/Sone.java @@ -28,7 +28,7 @@ import java.util.List; import java.util.Set; import net.pterodactylus.sone.core.Options; -import net.pterodactylus.sone.database.AlbumBuilderFactory; +import net.pterodactylus.sone.database.AlbumBuilder; import net.pterodactylus.sone.database.PostBuilder; import net.pterodactylus.sone.database.PostBuilderFactory; import net.pterodactylus.sone.freenet.wot.Identity; @@ -46,7 +46,7 @@ import com.google.common.primitives.Ints; * * @author David ‘Bombe’ Roden */ -public interface Sone extends Identified, Fingerprintable, PostBuilderFactory, AlbumBuilderFactory, Comparable { +public interface Sone extends Identified, Fingerprintable, PostBuilderFactory, Comparable { /** * Enumeration for the possible states of a {@link Sone}. @@ -549,6 +549,8 @@ public interface Sone extends Identified, Fingerprintable, PostBuilderFactory, A /* TODO - remove this method again, maybe add an option provider */ void setOptions(Options options); + AlbumBuilder newAlbumBuilder() throws IllegalStateException; + PostBuilder newPostBuilder(); } diff --git a/src/main/java/net/pterodactylus/sone/database/AlbumBuilderFactory.java b/src/main/java/net/pterodactylus/sone/database/AlbumBuilderFactory.java deleted file mode 100644 index e7a537d..0000000 --- a/src/main/java/net/pterodactylus/sone/database/AlbumBuilderFactory.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Sone - AlbumBuilderFactory.java - Copyright © 2013 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 - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package net.pterodactylus.sone.database; - -/** - * Factory for {@link AlbumBuilder}s. - * - * @author David ‘Bombe’ Roden - */ -public interface AlbumBuilderFactory { - - /** - * Creates a new album builder. - * - * @return A new album builder - */ - AlbumBuilder newAlbumBuilder(); - -} diff --git a/src/main/java/net/pterodactylus/sone/web/CreateAlbumPage.java b/src/main/java/net/pterodactylus/sone/web/CreateAlbumPage.java index 30e1e60..97c0e3b 100644 --- a/src/main/java/net/pterodactylus/sone/web/CreateAlbumPage.java +++ b/src/main/java/net/pterodactylus/sone/web/CreateAlbumPage.java @@ -21,7 +21,7 @@ import static net.pterodactylus.sone.text.TextFilter.filter; import net.pterodactylus.sone.data.Album; import net.pterodactylus.sone.data.Sone; -import net.pterodactylus.sone.database.AlbumBuilderFactory; +import net.pterodactylus.sone.database.AlbumBuilder; import net.pterodactylus.sone.web.page.FreenetRequest; import net.pterodactylus.util.template.Template; import net.pterodactylus.util.template.TemplateContext; @@ -71,8 +71,8 @@ public class CreateAlbumPage extends SoneTemplatePage { private Album createAlbum(FreenetRequest request, String name) { Sone currentSone = getCurrentSone(request.getToadletContext()); String parentId = request.getHttpRequest().getPartAsStringFailsafe("parent", 36); - AlbumBuilderFactory parent = parentId.equals("") ? currentSone : webInterface.getCore().getAlbum(parentId).get(); - Album album = parent.newAlbumBuilder().build(); + AlbumBuilder albumBuilder = parentId.equals("") ? currentSone.newAlbumBuilder() : webInterface.getCore().getAlbum(parentId).get().newAlbumBuilder(); + Album album = albumBuilder.build(); return setTitleAndDescription(request, name, album); } -- 2.7.4