From bc96c761a0f29c88f7685230408868deb640ce1d Mon Sep 17 00:00:00 2001 From: Alexander Capehart Date: Sun, 12 Feb 2023 19:17:40 -0700 Subject: [PATCH] music: remove stray real naming Replace stray Real* class names and replace them with the new Impl naming scheme. --- .../org/oxycblt/auxio/music/model/Library.kt | 28 ++--- .../model/{RealMusic.kt => MusicImpl.kt} | 100 +++++++++--------- .../org/oxycblt/auxio/music/model/RawMusic.kt | 14 +-- 3 files changed, 71 insertions(+), 71 deletions(-) rename app/src/main/java/org/oxycblt/auxio/music/model/{RealMusic.kt => MusicImpl.kt} (86%) diff --git a/app/src/main/java/org/oxycblt/auxio/music/model/Library.kt b/app/src/main/java/org/oxycblt/auxio/music/model/Library.kt index 502a9367f..4d9241bad 100644 --- a/app/src/main/java/org/oxycblt/auxio/music/model/Library.kt +++ b/app/src/main/java/org/oxycblt/auxio/music/model/Library.kt @@ -82,11 +82,11 @@ interface Library { * @param settings [MusicSettings] required. */ fun from(rawSongs: List, settings: MusicSettings): Library = - RealLibrary(rawSongs, settings) + LibraryImpl(rawSongs, settings) } } -private class RealLibrary(rawSongs: List, settings: MusicSettings) : Library { +private class LibraryImpl(rawSongs: List, settings: MusicSettings) : Library { override val songs = buildSongs(rawSongs, settings) override val albums = buildAlbums(songs) override val artists = buildArtists(songs, albums) @@ -125,15 +125,15 @@ private class RealLibrary(rawSongs: List, settings: MusicSettings) : Li } /** - * Build a list [RealSong]s from the given [RawSong]. - * @param rawSongs The [RawSong]s to build the [RealSong]s from. - * @param settings [MusicSettings] required to build [RealSong]s. - * @return A sorted list of [RealSong]s derived from the [RawSong] that should be suitable for + * Build a list [SongImpl]s from the given [RawSong]. + * @param rawSongs The [RawSong]s to build the [SongImpl]s from. + * @param settings [MusicSettings] required to build [SongImpl]s. + * @return A sorted list of [SongImpl]s derived from the [RawSong] that should be suitable for * grouping. */ private fun buildSongs(rawSongs: List, settings: MusicSettings) = Sort(Sort.Mode.ByName, Sort.Direction.ASCENDING) - .songs(rawSongs.map { RealSong(it, settings) }.distinct()) + .songs(rawSongs.map { SongImpl(it, settings) }.distinct()) /** * Build a list of [Album]s from the given [Song]s. @@ -142,11 +142,11 @@ private class RealLibrary(rawSongs: List, settings: MusicSettings) : Li * @return A non-empty list of [Album]s. These [Album]s will be incomplete and must be linked * with parent [Artist] instances in order to be usable. */ - private fun buildAlbums(songs: List): List { + private fun buildAlbums(songs: List): List { // Group songs by their singular raw album, then map the raw instances and their // grouped songs to Album values. Album.Raw will handle the actual grouping rules. val songsByAlbum = songs.groupBy { it.rawAlbum } - val albums = songsByAlbum.map { RealAlbum(it.key, it.value) } + val albums = songsByAlbum.map { AlbumImpl(it.key, it.value) } logD("Successfully built ${albums.size} albums") return albums } @@ -164,7 +164,7 @@ private class RealLibrary(rawSongs: List, settings: MusicSettings) : Li * @return A non-empty list of [Artist]s. These [Artist]s will consist of the combined groupings * of [Song]s and [Album]s. */ - private fun buildArtists(songs: List, albums: List): List { + private fun buildArtists(songs: List, albums: List): List { // Add every raw artist credited to each Song/Album to the grouping. This way, // different multi-artist combinations are not treated as different artists. val musicByArtist = mutableMapOf>() @@ -182,7 +182,7 @@ private class RealLibrary(rawSongs: List, settings: MusicSettings) : Li } // Convert the combined mapping into artist instances. - val artists = musicByArtist.map { RealArtist(it.key, it.value) } + val artists = musicByArtist.map { ArtistImpl(it.key, it.value) } logD("Successfully built ${artists.size} artists") return artists } @@ -194,10 +194,10 @@ private class RealLibrary(rawSongs: List, settings: MusicSettings) : Li * created. * @return A non-empty list of [Genre]s. */ - private fun buildGenres(songs: List): List { + private fun buildGenres(songs: List): List { // Add every raw genre credited to each Song to the grouping. This way, // different multi-genre combinations are not treated as different genres. - val songsByGenre = mutableMapOf>() + val songsByGenre = mutableMapOf>() for (song in songs) { for (rawGenre in song.rawGenres) { songsByGenre.getOrPut(rawGenre) { mutableListOf() }.add(song) @@ -205,7 +205,7 @@ private class RealLibrary(rawSongs: List, settings: MusicSettings) : Li } // Convert the mapping into genre instances. - val genres = songsByGenre.map { RealGenre(it.key, it.value) } + val genres = songsByGenre.map { GenreImpl(it.key, it.value) } logD("Successfully built ${genres.size} genres") return genres } diff --git a/app/src/main/java/org/oxycblt/auxio/music/model/RealMusic.kt b/app/src/main/java/org/oxycblt/auxio/music/model/MusicImpl.kt similarity index 86% rename from app/src/main/java/org/oxycblt/auxio/music/model/RealMusic.kt rename to app/src/main/java/org/oxycblt/auxio/music/model/MusicImpl.kt index 58ca45f37..736d7cb1f 100644 --- a/app/src/main/java/org/oxycblt/auxio/music/model/RealMusic.kt +++ b/app/src/main/java/org/oxycblt/auxio/music/model/MusicImpl.kt @@ -46,12 +46,12 @@ import org.oxycblt.auxio.util.toUuidOrNull import org.oxycblt.auxio.util.unlikelyToBeNull /** - * Library-backed implementation of [RealSong]. + * Library-backed implementation of [Song]. * @param rawSong The [RawSong] to derive the member data from. * @param musicSettings [MusicSettings] to perform further user-configured parsing. * @author Alexander Capehart (OxygenCobalt) */ -class RealSong(rawSong: RawSong, musicSettings: MusicSettings) : Song { +class SongImpl(rawSong: RawSong, musicSettings: MusicSettings) : Song { override val uid = // Attempt to use a MusicBrainz ID first before falling back to a hashed UID. rawSong.musicBrainzId?.toUuidOrNull()?.let { Music.UID.musicBrainz(MusicMode.SONGS, it) } @@ -90,7 +90,7 @@ class RealSong(rawSong: RawSong, musicSettings: MusicSettings) : Song { override val size = requireNotNull(rawSong.size) { "Invalid raw: No size" } override val durationMs = requireNotNull(rawSong.durationMs) { "Invalid raw: No duration" } override val dateAdded = requireNotNull(rawSong.dateAdded) { "Invalid raw: No date added" } - private var _album: RealAlbum? = null + private var _album: AlbumImpl? = null override val album: Album get() = unlikelyToBeNull(_album) @@ -121,7 +121,7 @@ class RealSong(rawSong: RawSong, musicSettings: MusicSettings) : Song { albumArtistSortNames.getOrNull(i)) } - private val _artists = mutableListOf() + private val _artists = mutableListOf() override val artists: List get() = _artists override fun resolveArtistContents(context: Context) = resolveNames(context, artists) @@ -137,14 +137,14 @@ class RealSong(rawSong: RawSong, musicSettings: MusicSettings) : Song { return true } - private val _genres = mutableListOf() + private val _genres = mutableListOf() override val genres: List get() = _genres override fun resolveGenreContents(context: Context) = resolveNames(context, genres) /** - * The [RawAlbum] instances collated by the [RealSong]. This can be used to group [RealSong]s - * into an [RealAlbum]. + * The [RawAlbum] instances collated by the [Song]. This can be used to group [Song]s + * into an [Album]. */ val rawAlbum = RawAlbum( @@ -159,16 +159,16 @@ class RealSong(rawSong: RawSong, musicSettings: MusicSettings) : Song { .ifEmpty { listOf(RawArtist(null, null)) }) /** - * The [RawArtist] instances collated by the [RealSong]. The artists of the song take priority, + * The [RawArtist] instances collated by the [Song]. The artists of the song take priority, * followed by the album artists. If there are no artists, this field will be a single "unknown" - * [RawArtist]. This can be used to group up [RealSong]s into an [RealArtist]. + * [RawArtist]. This can be used to group up [Song]s into an [Artist]. */ val rawArtists = rawIndividualArtists.ifEmpty { rawAlbumArtists }.ifEmpty { listOf(RawArtist()) } /** - * The [RawGenre] instances collated by the [RealSong]. This can be used to group up [RealSong]s - * into a [RealGenre]. ID3v2 Genre names are automatically converted to their resolved names. + * The [RawGenre] instances collated by the [Song]. This can be used to group up [Song]s + * into a [Genre]. ID3v2 Genre names are automatically converted to their resolved names. */ val rawGenres = rawSong.genreNames @@ -177,26 +177,26 @@ class RealSong(rawSong: RawSong, musicSettings: MusicSettings) : Song { .ifEmpty { listOf(RawGenre()) } /** - * Links this [RealSong] with a parent [RealAlbum]. - * @param album The parent [RealAlbum] to link to. + * Links this [Song] with a parent [Album]. + * @param album The parent [Album] to link to. */ - fun link(album: RealAlbum) { + fun link(album: AlbumImpl) { _album = album } /** - * Links this [RealSong] with a parent [RealArtist]. - * @param artist The parent [RealArtist] to link to. + * Links this [Song] with a parent [Artist]. + * @param artist The parent [Artist] to link to. */ - fun link(artist: RealArtist) { + fun link(artist: ArtistImpl) { _artists.add(artist) } /** - * Links this [RealSong] with a parent [RealGenre]. - * @param genre The parent [RealGenre] to link to. + * Links this [Song] with a parent [Genre]. + * @param genre The parent [Genre] to link to. */ - fun link(genre: RealGenre) { + fun link(genre: GenreImpl) { _genres.add(genre) } @@ -231,13 +231,13 @@ class RealSong(rawSong: RawSong, musicSettings: MusicSettings) : Song { } /** - * Library-backed implementation of [RealAlbum]. + * Library-backed implementation of [Album]. * @param rawAlbum The [RawAlbum] to derive the member data from. - * @param songs The [RealSong]s that are a part of this [RealAlbum]. These items will be linked to - * this [RealAlbum]. + * @param songs The [Song]s that are a part of this [Album]. These items will be linked to + * this [Album]. * @author Alexander Capehart (OxygenCobalt) */ -class RealAlbum(val rawAlbum: RawAlbum, override val songs: List) : Album { +class AlbumImpl(val rawAlbum: RawAlbum, override val songs: List) : Album { override val uid = // Attempt to use a MusicBrainz ID first before falling back to a hashed UID. rawAlbum.musicBrainzId?.let { Music.UID.musicBrainz(MusicMode.ALBUMS, it) } @@ -263,9 +263,9 @@ class RealAlbum(val rawAlbum: RawAlbum, override val songs: List) : Al // the same UID but different contents are not equal. override fun hashCode() = 31 * uid.hashCode() + songs.hashCode() override fun equals(other: Any?) = - other is RealAlbum && uid == other.uid && songs == other.songs + other is AlbumImpl && uid == other.uid && songs == other.songs - private val _artists = mutableListOf() + private val _artists = mutableListOf() override val artists: List get() = _artists override fun resolveArtistContents(context: Context) = resolveNames(context, artists) @@ -298,17 +298,17 @@ class RealAlbum(val rawAlbum: RawAlbum, override val songs: List) : Al } /** - * The [RawArtist] instances collated by the [RealAlbum]. The album artists of the song take + * The [RawArtist] instances collated by the [Album]. The album artists of the song take * priority, followed by the artists. If there are no artists, this field will be a single - * "unknown" [RawArtist]. This can be used to group up [RealAlbum]s into an [RealArtist]. + * "unknown" [RawArtist]. This can be used to group up [Album]s into an [Artist]. */ val rawArtists = rawAlbum.rawArtists /** - * Links this [RealAlbum] with a parent [RealArtist]. - * @param artist The parent [RealArtist] to link to. + * Links this [Album] with a parent [Artist]. + * @param artist The parent [Artist] to link to. */ - fun link(artist: RealArtist) { + fun link(artist: ArtistImpl) { _artists.add(artist) } @@ -332,14 +332,14 @@ class RealAlbum(val rawAlbum: RawAlbum, override val songs: List) : Al } /** - * Library-backed implementation of [RealArtist]. + * Library-backed implementation of [Artist]. * @param rawArtist The [RawArtist] to derive the member data from. - * @param songAlbums A list of the [RealSong]s and [RealAlbum]s that are a part of this [RealArtist] - * , either through artist or album artist tags. Providing [RealSong]s to the artist is optional. - * These instances will be linked to this [RealArtist]. + * @param songAlbums A list of the [Song]s and [Album]s that are a part of this [Artist] + * , either through artist or album artist tags. Providing [Song]s to the artist is optional. + * These instances will be linked to this [Artist]. * @author Alexander Capehart (OxygenCobalt) */ -class RealArtist(private val rawArtist: RawArtist, songAlbums: List) : Artist { +class ArtistImpl(private val rawArtist: RawArtist, songAlbums: List) : Artist { override val uid = // Attempt to use a MusicBrainz ID first before falling back to a hashed UID. rawArtist.musicBrainzId?.let { Music.UID.musicBrainz(MusicMode.ARTISTS, it) } @@ -358,7 +358,7 @@ class RealArtist(private val rawArtist: RawArtist, songAlbums: List) : Ar // the same UID but different contents are not equal. override fun hashCode() = 31 * uid.hashCode() + songs.hashCode() override fun equals(other: Any?) = - other is RealArtist && uid == other.uid && songs == other.songs + other is ArtistImpl && uid == other.uid && songs == other.songs override lateinit var genres: List override fun resolveGenreContents(context: Context) = resolveNames(context, genres) @@ -382,12 +382,12 @@ class RealArtist(private val rawArtist: RawArtist, songAlbums: List) : Ar for (music in songAlbums) { when (music) { - is RealSong -> { + is SongImpl -> { music.link(this) distinctSongs.add(music) distinctAlbums.add(music.album) } - is RealAlbum -> { + is AlbumImpl -> { music.link(this) distinctAlbums.add(music) noAlbums = false @@ -403,12 +403,12 @@ class RealArtist(private val rawArtist: RawArtist, songAlbums: List) : Ar } /** - * Returns the original position of this [RealArtist]'s [RawArtist] within the given [RawArtist] - * list. This can be used to create a consistent ordering within child [RealArtist] lists based + * Returns the original position of this [Artist]'s [RawArtist] within the given [RawArtist] + * list. This can be used to create a consistent ordering within child [Artist] lists based * on the original tag order. - * @param rawArtists The [RawArtist] instances to check. It is assumed that this [RealArtist]'s + * @param rawArtists The [RawArtist] instances to check. It is assumed that this [Artist]'s * [RawArtist] will be within the list. - * @return The index of the [RealArtist]'s [RawArtist] within the list. + * @return The index of the [Artist]'s [RawArtist] within the list. */ fun getOriginalPositionIn(rawArtists: List) = rawArtists.indexOf(rawArtist) @@ -426,10 +426,10 @@ class RealArtist(private val rawArtist: RawArtist, songAlbums: List) : Ar } } /** - * Library-backed implementation of [RealGenre]. + * Library-backed implementation of [Genre]. * @author Alexander Capehart (OxygenCobalt) */ -class RealGenre(private val rawGenre: RawGenre, override val songs: List) : Genre { +class GenreImpl(private val rawGenre: RawGenre, override val songs: List) : Genre { override val uid = Music.UID.auxio(MusicMode.GENRES) { update(rawGenre.name) } override val rawName = rawGenre.name override val rawSortName = rawName @@ -444,7 +444,7 @@ class RealGenre(private val rawGenre: RawGenre, override val songs: List() @@ -467,12 +467,12 @@ class RealGenre(private val rawGenre: RawGenre, override val songs: List) = rawGenres.indexOf(rawGenre) diff --git a/app/src/main/java/org/oxycblt/auxio/music/model/RawMusic.kt b/app/src/main/java/org/oxycblt/auxio/music/model/RawMusic.kt index 5ed44d775..f532266c7 100644 --- a/app/src/main/java/org/oxycblt/auxio/music/model/RawMusic.kt +++ b/app/src/main/java/org/oxycblt/auxio/music/model/RawMusic.kt @@ -23,18 +23,18 @@ import org.oxycblt.auxio.music.metadata.* import org.oxycblt.auxio.music.storage.Directory /** - * Raw information about a [RealSong] obtained from the filesystem/Extractor instances. + * Raw information about a [SongImpl] obtained from the filesystem/Extractor instances. * @author Alexander Capehart (OxygenCobalt) */ class RawSong( /** - * The ID of the [RealSong]'s audio file, obtained from MediaStore. Note that this ID is highly + * The ID of the [SongImpl]'s audio file, obtained from MediaStore. Note that this ID is highly * unstable and should only be used for accessing the audio file. */ var mediaStoreId: Long? = null, /** @see Song.dateAdded */ var dateAdded: Long? = null, - /** The latest date the [RealSong]'s audio file was modified, as a unix epoch timestamp. */ + /** The latest date the [SongImpl]'s audio file was modified, as a unix epoch timestamp. */ var dateModified: Long? = null, /** @see Song.path */ var fileName: String? = null, @@ -87,12 +87,12 @@ class RawSong( ) /** - * Raw information about an [RealAlbum] obtained from the component [RealSong] instances. + * Raw information about an [AlbumImpl] obtained from the component [SongImpl] instances. * @author Alexander Capehart (OxygenCobalt) */ class RawAlbum( /** - * The ID of the [RealAlbum]'s grouping, obtained from MediaStore. Note that this ID is highly + * The ID of the [AlbumImpl]'s grouping, obtained from MediaStore. Note that this ID is highly * unstable and should only be used for accessing the system-provided cover art. */ val mediaStoreId: Long, @@ -132,7 +132,7 @@ class RawAlbum( } /** - * Raw information about an [RealArtist] obtained from the component [RealSong] and [RealAlbum] + * Raw information about an [ArtistImpl] obtained from the component [SongImpl] and [AlbumImpl] * instances. * @author Alexander Capehart (OxygenCobalt) */ @@ -174,7 +174,7 @@ class RawArtist( } /** - * Raw information about a [RealGenre] obtained from the component [RealSong] instances. + * Raw information about a [GenreImpl] obtained from the component [SongImpl] instances. * @author Alexander Capehart (OxygenCobalt) */ class RawGenre(