From 53dc7c16657d8a4ceec7a14e806ab6247bac30ab Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sun, 15 Oct 2017 17:48:31 +0200 Subject: [PATCH] Replace image-related interface with Kotlin versions --- .../pterodactylus/sone/database/ImageBuilder.java | 34 ---------------------- .../sone/database/ImageBuilderFactory.java | 29 ------------------ .../pterodactylus/sone/database/ImageDatabase.java | 30 ------------------- .../pterodactylus/sone/database/ImageProvider.java | 33 --------------------- .../pterodactylus/sone/database/ImageStore.java | 33 --------------------- .../pterodactylus/sone/database/ImageBuilder.kt | 31 ++++++++++++++++++++ .../sone/database/ImageBuilderFactory.kt | 27 +++++++++++++++++ .../pterodactylus/sone/database/ImageDatabase.kt | 24 +++++++++++++++ .../pterodactylus/sone/database/ImageProvider.kt | 31 ++++++++++++++++++++ .../net/pterodactylus/sone/database/ImageStore.kt | 30 +++++++++++++++++++ 10 files changed, 143 insertions(+), 159 deletions(-) delete mode 100644 src/main/java/net/pterodactylus/sone/database/ImageBuilder.java delete mode 100644 src/main/java/net/pterodactylus/sone/database/ImageBuilderFactory.java delete mode 100644 src/main/java/net/pterodactylus/sone/database/ImageDatabase.java delete mode 100644 src/main/java/net/pterodactylus/sone/database/ImageProvider.java delete mode 100644 src/main/java/net/pterodactylus/sone/database/ImageStore.java create mode 100644 src/main/kotlin/net/pterodactylus/sone/database/ImageBuilder.kt create mode 100644 src/main/kotlin/net/pterodactylus/sone/database/ImageBuilderFactory.kt create mode 100644 src/main/kotlin/net/pterodactylus/sone/database/ImageDatabase.kt create mode 100644 src/main/kotlin/net/pterodactylus/sone/database/ImageProvider.kt create mode 100644 src/main/kotlin/net/pterodactylus/sone/database/ImageStore.kt diff --git a/src/main/java/net/pterodactylus/sone/database/ImageBuilder.java b/src/main/java/net/pterodactylus/sone/database/ImageBuilder.java deleted file mode 100644 index 7b5c9e0..0000000 --- a/src/main/java/net/pterodactylus/sone/database/ImageBuilder.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Sone - ImageBuilder.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.Image; - -/** - * Builder for {@link Image} objects. - * - * @author David Roden - */ -public interface ImageBuilder { - - ImageBuilder randomId(); - - ImageBuilder withId(String id); - - Image build() throws IllegalStateException; - -} diff --git a/src/main/java/net/pterodactylus/sone/database/ImageBuilderFactory.java b/src/main/java/net/pterodactylus/sone/database/ImageBuilderFactory.java deleted file mode 100644 index 900c989..0000000 --- a/src/main/java/net/pterodactylus/sone/database/ImageBuilderFactory.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Sone - ImageBuilderFactory.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 ImageBuilder}s. - * - * @author David Roden - */ -public interface ImageBuilderFactory { - - ImageBuilder newImageBuilder(); - -} diff --git a/src/main/java/net/pterodactylus/sone/database/ImageDatabase.java b/src/main/java/net/pterodactylus/sone/database/ImageDatabase.java deleted file mode 100644 index 090aa3b..0000000 --- a/src/main/java/net/pterodactylus/sone/database/ImageDatabase.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Sone - ImageDatabase.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 ImageProvider}, an {@link ImageBuilderFactory}, and an - * {@link ImageStore} into an image database. - * - * @author David ‘Bombe’ Roden - */ -public interface ImageDatabase extends ImageProvider, ImageBuilderFactory, ImageStore { - - /* nothing here. */ - -} diff --git a/src/main/java/net/pterodactylus/sone/database/ImageProvider.java b/src/main/java/net/pterodactylus/sone/database/ImageProvider.java deleted file mode 100644 index 8ee3e5f..0000000 --- a/src/main/java/net/pterodactylus/sone/database/ImageProvider.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Sone - ImageProvider.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.Image; - -import com.google.common.base.Optional; - -/** - * Provides {@link Image}. - * - * @author David Roden - */ -public interface ImageProvider { - - Optional getImage(String imageId); - -} diff --git a/src/main/java/net/pterodactylus/sone/database/ImageStore.java b/src/main/java/net/pterodactylus/sone/database/ImageStore.java deleted file mode 100644 index 97a7240..0000000 --- a/src/main/java/net/pterodactylus/sone/database/ImageStore.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Sone - ImageStore.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.Image; - -/** - * Manages {@link Image} storage. - * - * @author David Roden - */ -public interface ImageStore { - - void storeImage(Image image); - - void removeImage(Image image); - -} diff --git a/src/main/kotlin/net/pterodactylus/sone/database/ImageBuilder.kt b/src/main/kotlin/net/pterodactylus/sone/database/ImageBuilder.kt new file mode 100644 index 0000000..5ceb28e --- /dev/null +++ b/src/main/kotlin/net/pterodactylus/sone/database/ImageBuilder.kt @@ -0,0 +1,31 @@ +/* + * Sone - ImageBuilder.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.Image + +/** + * Builder for [Image] objects. + */ +interface ImageBuilder { + + fun randomId(): ImageBuilder + fun withId(id: String): ImageBuilder + + fun build(): Image + +} diff --git a/src/main/kotlin/net/pterodactylus/sone/database/ImageBuilderFactory.kt b/src/main/kotlin/net/pterodactylus/sone/database/ImageBuilderFactory.kt new file mode 100644 index 0000000..bae797c --- /dev/null +++ b/src/main/kotlin/net/pterodactylus/sone/database/ImageBuilderFactory.kt @@ -0,0 +1,27 @@ +/* + * Sone - ImageBuilderFactory.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 [ImageBuilder]s. + */ +interface ImageBuilderFactory { + + fun newImageBuilder(): ImageBuilder + +} diff --git a/src/main/kotlin/net/pterodactylus/sone/database/ImageDatabase.kt b/src/main/kotlin/net/pterodactylus/sone/database/ImageDatabase.kt new file mode 100644 index 0000000..4617cef --- /dev/null +++ b/src/main/kotlin/net/pterodactylus/sone/database/ImageDatabase.kt @@ -0,0 +1,24 @@ +/* + * Sone - ImageDatabase.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 [ImageProvider], an [ImageBuilderFactory], and an + * [ImageStore] into an image database. + */ +interface ImageDatabase : ImageProvider, ImageBuilderFactory, ImageStore diff --git a/src/main/kotlin/net/pterodactylus/sone/database/ImageProvider.kt b/src/main/kotlin/net/pterodactylus/sone/database/ImageProvider.kt new file mode 100644 index 0000000..987c52f --- /dev/null +++ b/src/main/kotlin/net/pterodactylus/sone/database/ImageProvider.kt @@ -0,0 +1,31 @@ +/* + * Sone - ImageProvider.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.Image + +import com.google.common.base.Optional + +/** + * Provides [Image]s. + */ +interface ImageProvider { + + fun getImage(imageId: String): Optional + +} diff --git a/src/main/kotlin/net/pterodactylus/sone/database/ImageStore.kt b/src/main/kotlin/net/pterodactylus/sone/database/ImageStore.kt new file mode 100644 index 0000000..91cff2d --- /dev/null +++ b/src/main/kotlin/net/pterodactylus/sone/database/ImageStore.kt @@ -0,0 +1,30 @@ +/* + * Sone - ImageStore.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.Image + +/** + * Manages [Image] storage. + */ +interface ImageStore { + + fun storeImage(image: Image) + fun removeImage(image: Image) + +} -- 2.7.4