Reorder imports.
[Sone.git] / src / main / java / net / pterodactylus / sone / data / Sone.java
index a3e872b..a895585 100644 (file)
@@ -17,8 +17,7 @@
 
 package net.pterodactylus.sone.data;
 
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.*;
 
 import java.util.ArrayList;
 import java.util.Collection;
@@ -37,12 +36,13 @@ import net.pterodactylus.sone.freenet.wot.OwnIdentity;
 import net.pterodactylus.sone.template.SoneAccessor;
 import net.pterodactylus.util.logging.Logging;
 
+import freenet.keys.FreenetURI;
+
 import com.google.common.base.Predicate;
+import com.google.common.collect.FluentIterable;
 import com.google.common.hash.Hasher;
 import com.google.common.hash.Hashing;
 
-import freenet.keys.FreenetURI;
-
 /**
  * A Sone defines everything about a user: her profile, her status updates, her
  * replies, her likes and dislikes, etc.
@@ -770,27 +770,6 @@ public class Sone implements Fingerprintable, Comparable<Sone> {
        }
 
        /**
-        * 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<Album> getAllAlbums() {
-               List<Album> flatAlbums = new ArrayList<Album>();
-               flatAlbums.addAll(albums);
-               int lastAlbumIndex = 0;
-               while (lastAlbumIndex < flatAlbums.size()) {
-                       int previousAlbumCount = flatAlbums.size();
-                       for (Album album : new ArrayList<Album>(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 +777,7 @@ public class Sone implements Fingerprintable, Comparable<Sone> {
         */
        public List<Image> getAllImages() {
                List<Image> allImages = new ArrayList<Image>();
-               for (Album album : getAllAlbums()) {
+               for (Album album : FluentIterable.from(getAlbums()).transformAndConcat(Album.FLATTENER).toList()) {
                        allImages.addAll(album.getImages());
                }
                return allImages;