Add function that returns all images for a Sone.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 18 Sep 2014 19:41:20 +0000 (21:41 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 18 Sep 2014 19:41:20 +0000 (21:41 +0200)
src/main/java/net/pterodactylus/sone/data/Sone.java

index 6df84df..55e5fff 100644 (file)
@@ -191,6 +191,15 @@ public interface Sone extends Identified, Fingerprintable, Comparable<Sone> {
                }
        };
 
+       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.
         *