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;
}
};
- public static final Function<Sone, List<Image>> toAllImages = new Function<Sone, List<Image>>() {
- @Override
- public List<Image> apply(@Nullable Sone sone) {
- return (sone == null) ? Collections.<Image>emptyList() :
- from(FLATTENER.apply(sone.getRootAlbum()))
- .transformAndConcat(IMAGES).toList();
- }
- };
-
/**
* Returns the identity of this Sone.
*
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
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 }
}
}
}
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.*
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