Store all albums and images in the database after loading them from the configuration.
[Sone.git] / src / main / java / net / pterodactylus / sone / data / Sone.java
index 1b76588..6df84df 100644 (file)
@@ -23,6 +23,7 @@ import static net.pterodactylus.sone.data.Album.FLATTENER;
 import static net.pterodactylus.sone.data.Album.IMAGES;
 
 import java.util.Collection;
+import java.util.Collections;
 import java.util.Comparator;
 import java.util.List;
 import java.util.Set;
@@ -182,6 +183,14 @@ public interface Sone extends Identified, Fingerprintable, Comparable<Sone> {
                                }
                        };
 
+       public static final Function<Sone, List<Album>> toAllAlbums = new Function<Sone, List<Album>>() {
+               @Override
+               public List<Album> apply(@Nullable Sone sone) {
+                       return (sone == null) ? Collections.<Album>emptyList() : FLATTENER.apply(
+                                       sone.getRootAlbum());
+               }
+       };
+
        /**
         * Returns the identity of this Sone.
         *