From d98bd42433b94ba26460ca99495805dca3b06481 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Tue, 18 Feb 2020 14:37:50 +0100 Subject: [PATCH] =?utf8?q?=F0=9F=94=A5=20Remove=20function=20from=20Sone?= =?utf8?q?=20interface?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/main/java/net/pterodactylus/sone/data/Sone.java | 11 ----------- .../net/pterodactylus/sone/database/memory/MemoryDatabase.kt | 8 ++++---- src/test/kotlin/net/pterodactylus/sone/core/SoneParserTest.kt | 2 ++ 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/src/main/java/net/pterodactylus/sone/data/Sone.java b/src/main/java/net/pterodactylus/sone/data/Sone.java index 836baa1..843400e 100644 --- a/src/main/java/net/pterodactylus/sone/data/Sone.java +++ b/src/main/java/net/pterodactylus/sone/data/Sone.java @@ -17,9 +17,7 @@ package net.pterodactylus.sone.data; -import static com.google.common.collect.FluentIterable.from; import static net.pterodactylus.sone.data.Album.FLATTENER; -import static net.pterodactylus.sone.data.Album.IMAGES; import java.util.Collection; import java.util.Collections; @@ -67,15 +65,6 @@ public interface Sone extends Identified, Fingerprintable, Comparable { } }; - public static final Function> toAllImages = new Function>() { - @Override - public List apply(@Nullable Sone sone) { - return (sone == null) ? Collections.emptyList() : - from(FLATTENER.apply(sone.getRootAlbum())) - .transformAndConcat(IMAGES).toList(); - } - }; - /** * Returns the identity of this Sone. * diff --git a/src/main/kotlin/net/pterodactylus/sone/database/memory/MemoryDatabase.kt b/src/main/kotlin/net/pterodactylus/sone/database/memory/MemoryDatabase.kt index 8722873..e62d968 100644 --- a/src/main/kotlin/net/pterodactylus/sone/database/memory/MemoryDatabase.kt +++ b/src/main/kotlin/net/pterodactylus/sone/database/memory/MemoryDatabase.kt @@ -31,7 +31,7 @@ import net.pterodactylus.sone.data.PostReply import net.pterodactylus.sone.data.Reply.TIME_COMPARATOR import net.pterodactylus.sone.data.Sone import net.pterodactylus.sone.data.Sone.toAllAlbums -import net.pterodactylus.sone.data.Sone.toAllImages +import net.pterodactylus.sone.data.allImages import net.pterodactylus.sone.data.impl.AlbumBuilderImpl import net.pterodactylus.sone.data.impl.ImageBuilderImpl import net.pterodactylus.sone.database.AlbumBuilder @@ -127,9 +127,9 @@ class MemoryDatabase @Inject constructor(private val configuration: Configuratio for (album in toAllAlbums.apply(sone)!!) { allAlbums[album.id] = album } - soneImages.putAll(sone.id, toAllImages.apply(sone)!!) - for (image in toAllImages.apply(sone)!!) { - allImages[image.id] = image + sone.rootAlbum.allImages.let { images -> + soneImages.putAll(sone.id, images) + images.forEach { image -> allImages[image.id] = image } } } } diff --git a/src/test/kotlin/net/pterodactylus/sone/core/SoneParserTest.kt b/src/test/kotlin/net/pterodactylus/sone/core/SoneParserTest.kt index 336d855..38419a2 100644 --- a/src/test/kotlin/net/pterodactylus/sone/core/SoneParserTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/core/SoneParserTest.kt @@ -5,6 +5,7 @@ import com.google.common.base.Optional.* import freenet.crypt.* import freenet.keys.InsertableClientSSK.* import net.pterodactylus.sone.data.* +import net.pterodactylus.sone.data.impl.AlbumImpl import net.pterodactylus.sone.database.memory.* import net.pterodactylus.sone.freenet.wot.* import net.pterodactylus.sone.test.* @@ -41,6 +42,7 @@ class SoneParserTest { whenever(sone.identity).thenReturn(identity) whenever(sone.requestUri).thenAnswer { clientSSK.uri.setKeyType("USK").setDocName("Sone") } whenever(sone.time).thenReturn(currentTimeMillis() - DAYS.toMillis(1)) + whenever(sone.rootAlbum).thenReturn(AlbumImpl(sone)) } @Test -- 2.7.4