From 4e8279b445fb3087582fe715a30df2a7633b63b4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sun, 15 Oct 2017 19:17:27 +0200 Subject: [PATCH] Replace album-related interfaces with Kotlin versions --- .../pterodactylus/sone/database/AlbumBuilder.java | 57 ---------------------- .../pterodactylus/sone/database/AlbumBuilder.kt | 35 +++++++++++++ .../sone/database/AlbumBuilderFactory.java | 34 ------------- .../sone/database/AlbumBuilderFactory.kt | 27 ++++++++++ .../pterodactylus/sone/database/AlbumDatabase.java | 30 ------------ .../pterodactylus/sone/database/AlbumDatabase.kt | 24 +++++++++ .../pterodactylus/sone/database/AlbumProvider.java | 41 ---------------- .../pterodactylus/sone/database/AlbumProvider.kt | 31 ++++++++++++ .../pterodactylus/sone/database/AlbumStore.java | 45 ----------------- .../net/pterodactylus/sone/database/AlbumStore.kt | 30 ++++++++++++ 10 files changed, 147 insertions(+), 207 deletions(-) delete mode 100644 src/main/java/net/pterodactylus/sone/database/AlbumBuilder.java create mode 100644 src/main/java/net/pterodactylus/sone/database/AlbumBuilder.kt delete mode 100644 src/main/java/net/pterodactylus/sone/database/AlbumBuilderFactory.java create mode 100644 src/main/java/net/pterodactylus/sone/database/AlbumBuilderFactory.kt delete mode 100644 src/main/java/net/pterodactylus/sone/database/AlbumDatabase.java create mode 100644 src/main/java/net/pterodactylus/sone/database/AlbumDatabase.kt delete mode 100644 src/main/java/net/pterodactylus/sone/database/AlbumProvider.java create mode 100644 src/main/java/net/pterodactylus/sone/database/AlbumProvider.kt delete mode 100644 src/main/java/net/pterodactylus/sone/database/AlbumStore.java create mode 100644 src/main/java/net/pterodactylus/sone/database/AlbumStore.kt diff --git a/src/main/java/net/pterodactylus/sone/database/AlbumBuilder.java b/src/main/java/net/pterodactylus/sone/database/AlbumBuilder.java deleted file mode 100644 index 2460306..0000000 --- a/src/main/java/net/pterodactylus/sone/database/AlbumBuilder.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Sone - AlbumBuilder.java - Copyright © 2013–2016 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; - -import net.pterodactylus.sone.data.Album; -import net.pterodactylus.sone.data.Sone; - -/** - * Builder for {@link Album} objects. - * - * @author David ‘Bombe’ Roden - */ -public interface AlbumBuilder { - - /** - * Configures this builder to create an album with a random ID. - * - * @return This album builder - */ - AlbumBuilder randomId(); - - /** - * Configures this builder to create an album with the given ID. - * - * @param id - * The ID of the album - * @return This album builder - */ - AlbumBuilder withId(String id); - - AlbumBuilder by(Sone sone); - - /** - * Creates the album. - * - * @return The created album - * @throws IllegalStateException - * if the album could not be created - */ - Album build() throws IllegalStateException; - -} diff --git a/src/main/java/net/pterodactylus/sone/database/AlbumBuilder.kt b/src/main/java/net/pterodactylus/sone/database/AlbumBuilder.kt new file mode 100644 index 0000000..ed441e0 --- /dev/null +++ b/src/main/java/net/pterodactylus/sone/database/AlbumBuilder.kt @@ -0,0 +1,35 @@ +/* + * Sone - AlbumBuilder.java - Copyright © 2013–2016 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 + +import net.pterodactylus.sone.data.Album +import net.pterodactylus.sone.data.Sone + +/** + * Builder for [Album] objects. + */ +interface AlbumBuilder { + + fun randomId(): AlbumBuilder + fun withId(id: String): AlbumBuilder + + fun by(sone: Sone): AlbumBuilder + + fun build(): Album + +} 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 07d7ae0..0000000 --- a/src/main/java/net/pterodactylus/sone/database/AlbumBuilderFactory.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Sone - AlbumBuilderFactory.java - Copyright © 2013–2016 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/database/AlbumBuilderFactory.kt b/src/main/java/net/pterodactylus/sone/database/AlbumBuilderFactory.kt new file mode 100644 index 0000000..6f854db --- /dev/null +++ b/src/main/java/net/pterodactylus/sone/database/AlbumBuilderFactory.kt @@ -0,0 +1,27 @@ +/* + * Sone - AlbumBuilderFactory.java - Copyright © 2013–2016 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 [AlbumBuilder]s. + */ +interface AlbumBuilderFactory { + + fun newAlbumBuilder(): AlbumBuilder + +} diff --git a/src/main/java/net/pterodactylus/sone/database/AlbumDatabase.java b/src/main/java/net/pterodactylus/sone/database/AlbumDatabase.java deleted file mode 100644 index 8e6fa45..0000000 --- a/src/main/java/net/pterodactylus/sone/database/AlbumDatabase.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Sone - AlbumDatabase.java - Copyright © 2013–2016 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; - -/** - * Combines an {@link AlbumProvider} and an {@link AlbumStore} into an album - * database. - * - * @author David ‘Bombe’ Roden - */ -public interface AlbumDatabase extends AlbumProvider, AlbumBuilderFactory, AlbumStore { - - /* nothing here. */ - -} diff --git a/src/main/java/net/pterodactylus/sone/database/AlbumDatabase.kt b/src/main/java/net/pterodactylus/sone/database/AlbumDatabase.kt new file mode 100644 index 0000000..69daa21 --- /dev/null +++ b/src/main/java/net/pterodactylus/sone/database/AlbumDatabase.kt @@ -0,0 +1,24 @@ +/* + * Sone - AlbumDatabase.java - Copyright © 2013–2016 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 + +/** + * Combines an [AlbumProvider] and an [AlbumStore] into an album + * database. + */ +interface AlbumDatabase : AlbumProvider, AlbumBuilderFactory, AlbumStore diff --git a/src/main/java/net/pterodactylus/sone/database/AlbumProvider.java b/src/main/java/net/pterodactylus/sone/database/AlbumProvider.java deleted file mode 100644 index 746f014..0000000 --- a/src/main/java/net/pterodactylus/sone/database/AlbumProvider.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Sone - AlbumProvider.java - Copyright © 2013–2016 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; - -import net.pterodactylus.sone.data.Album; - -import com.google.common.base.Optional; - -/** - * Interface for objects that can provide {@link Album}s by their ID. - * - * @author David ‘Bombe’ Roden - */ -public interface AlbumProvider { - - /** - * Returns the album with the given ID, or {@link Optional#absent()} if no such - * album exists. - * - * @param albumId - * The ID of the album - * @return The album, or {@link Optional#absent()} if the album does not exist - */ - Optional getAlbum(String albumId); - -} diff --git a/src/main/java/net/pterodactylus/sone/database/AlbumProvider.kt b/src/main/java/net/pterodactylus/sone/database/AlbumProvider.kt new file mode 100644 index 0000000..0ad0c67 --- /dev/null +++ b/src/main/java/net/pterodactylus/sone/database/AlbumProvider.kt @@ -0,0 +1,31 @@ +/* + * Sone - AlbumProvider.java - Copyright © 2013–2016 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 + +import net.pterodactylus.sone.data.Album + +import com.google.common.base.Optional + +/** + * Interface for objects that can provide [Album]s by their ID. + */ +interface AlbumProvider { + + fun getAlbum(albumId: String): Optional + +} diff --git a/src/main/java/net/pterodactylus/sone/database/AlbumStore.java b/src/main/java/net/pterodactylus/sone/database/AlbumStore.java deleted file mode 100644 index 2a9bfd0..0000000 --- a/src/main/java/net/pterodactylus/sone/database/AlbumStore.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Sone - AlbumStore.java - Copyright © 2013–2016 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; - -import net.pterodactylus.sone.data.Album; - -/** - * Interface for a store of albums. - * - * @author David ‘Bombe’ Roden - */ -public interface AlbumStore { - - /** - * Stores the given album. - * - * @param album - * The album to store - */ - void storeAlbum(Album album); - - /** - * Removes the given album from the store. - * - * @param album - * The album to remove - */ - void removeAlbum(Album album); - -} diff --git a/src/main/java/net/pterodactylus/sone/database/AlbumStore.kt b/src/main/java/net/pterodactylus/sone/database/AlbumStore.kt new file mode 100644 index 0000000..e2a31c7 --- /dev/null +++ b/src/main/java/net/pterodactylus/sone/database/AlbumStore.kt @@ -0,0 +1,30 @@ +/* + * Sone - AlbumStore.java - Copyright © 2013–2016 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 + +import net.pterodactylus.sone.data.Album + +/** + * Interface for a store of albums. + */ +interface AlbumStore { + + fun storeAlbum(album: Album) + fun removeAlbum(album: Album) + +} -- 2.7.4