🎨 Add Sone.allImages accessor
[Sone.git] / src / main / kotlin / net / pterodactylus / sone / data / Albums.kt
index 081a2fa..a38e9dd 100644 (file)
@@ -20,7 +20,7 @@ package net.pterodactylus.sone.data
 /** Returns all images contained in this album and all its albums. */
 val Album.allImages: Collection<Image>
        get() =
-               images + albums.flatMap { it.allImages }
+               images + albums.flatMap(Album::allImages)
 
 /**
  *  Returns this album and all albums contained in this album (recursively).
@@ -29,3 +29,10 @@ val Album.allImages: Collection<Image>
 val Album.allAlbums: List<Album>
        get() =
                listOf(this) + albums.flatMap(Album::allAlbums)
+
+@get:JvmName("notEmpty")
+val notEmpty: (Album) -> Boolean = { album ->
+       album.allImages.let { images ->
+               images.isNotEmpty() && images.any(Image::isInserted)
+       }
+}