X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fdata%2FSone.java;fp=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fdata%2FSone.java;h=8b08b17c7f0f9af275546d10899ff0e663ed6628;hp=a3e872b76f92960282e8c70310a6a0c40c396f44;hb=de928fae67034e4694d7d8e8ea73573d400491f4;hpb=0382e0afaa2bf1c193f4092a6468c99ff942df0c diff --git a/src/main/java/net/pterodactylus/sone/data/Sone.java b/src/main/java/net/pterodactylus/sone/data/Sone.java index a3e872b..8b08b17 100644 --- a/src/main/java/net/pterodactylus/sone/data/Sone.java +++ b/src/main/java/net/pterodactylus/sone/data/Sone.java @@ -38,6 +38,7 @@ import net.pterodactylus.sone.template.SoneAccessor; import net.pterodactylus.util.logging.Logging; import com.google.common.base.Predicate; +import com.google.common.collect.FluentIterable; import com.google.common.hash.Hasher; import com.google.common.hash.Hashing; @@ -770,27 +771,6 @@ public class Sone implements Fingerprintable, Comparable { } /** - * Returns a flattened list of all albums of this Sone. The resulting list - * contains parent albums before child albums so that the resulting list can - * be parsed in a single pass. - * - * @return The flattened albums - */ - public List getAllAlbums() { - List flatAlbums = new ArrayList(); - flatAlbums.addAll(albums); - int lastAlbumIndex = 0; - while (lastAlbumIndex < flatAlbums.size()) { - int previousAlbumCount = flatAlbums.size(); - for (Album album : new ArrayList(flatAlbums.subList(lastAlbumIndex, flatAlbums.size()))) { - flatAlbums.addAll(album.getAlbums()); - } - lastAlbumIndex = previousAlbumCount; - } - return flatAlbums; - } - - /** * Returns all images of a Sone. Images of a album are inserted into this * list before images of all child albums. * @@ -798,7 +778,7 @@ public class Sone implements Fingerprintable, Comparable { */ public List getAllImages() { List allImages = new ArrayList(); - for (Album album : getAllAlbums()) { + for (Album album : FluentIterable.from(getAlbums()).transformAndConcat(Album.FLATTENER).toList()) { allImages.addAll(album.getImages()); } return allImages;