🔥 Replace NOT_EMPTY with Kotlin version
[Sone.git] / src / main / kotlin / net / pterodactylus / sone / data / Albums.kt
index 0c79a84..da71d62 100644 (file)
@@ -21,3 +21,18 @@ package net.pterodactylus.sone.data
 val Album.allImages: Collection<Image>
        get() =
                images + albums.flatMap { it.allImages }
+
+/**
+ *  Returns this album and all albums contained in this album (recursively).
+ * A child album is always listed after its parent.
+ */
+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)
+       }
+}