Make Room models @Immutable

This commit is contained in:
vfsfitvnm 2022-08-26 10:30:02 +02:00
parent e7d768e6bd
commit 305d6c80c5
12 changed files with 24 additions and 0 deletions

View file

@ -1,8 +1,10 @@
package it.vfsfitvnm.vimusic.models
import androidx.compose.runtime.Immutable
import androidx.room.Entity
import androidx.room.PrimaryKey
@Immutable
@Entity
data class Album(
@PrimaryKey val id: String,

View file

@ -1,8 +1,10 @@
package it.vfsfitvnm.vimusic.models
import androidx.compose.runtime.Immutable
import androidx.room.Entity
import androidx.room.PrimaryKey
@Immutable
@Entity
data class Artist(
@PrimaryKey val id: String,

View file

@ -1,8 +1,10 @@
package it.vfsfitvnm.vimusic.models
import androidx.compose.runtime.Immutable
import androidx.room.Junction
import androidx.room.Relation
@Immutable
open class DetailedSong(
val id: String,
val title: String,

View file

@ -1,7 +1,9 @@
package it.vfsfitvnm.vimusic.models
import androidx.compose.runtime.Immutable
import androidx.room.Relation
@Immutable
class DetailedSongWithContentLength(
id: String,
title: String,

View file

@ -1,8 +1,10 @@
package it.vfsfitvnm.vimusic.models
import androidx.compose.runtime.Immutable
import androidx.room.Entity
import androidx.room.PrimaryKey
@Immutable
@Entity
data class Playlist(
@PrimaryKey(autoGenerate = true) val id: Long = 0,

View file

@ -1,7 +1,9 @@
package it.vfsfitvnm.vimusic.models
import androidx.compose.runtime.Immutable
import androidx.room.Embedded
@Immutable
data class PlaylistPreview(
@Embedded val playlist: Playlist,
val songCount: Int

View file

@ -1,9 +1,11 @@
package it.vfsfitvnm.vimusic.models
import androidx.compose.runtime.Immutable
import androidx.room.Embedded
import androidx.room.Junction
import androidx.room.Relation
@Immutable
data class PlaylistWithSongs(
@Embedded val playlist: Playlist,
@Relation(

View file

@ -1,10 +1,12 @@
package it.vfsfitvnm.vimusic.models
import androidx.compose.runtime.Immutable
import androidx.media3.common.MediaItem
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey
@Immutable
@Entity
class QueuedMediaItem(
@PrimaryKey(autoGenerate = true) val id: Long = 0,

View file

@ -1,8 +1,10 @@
package it.vfsfitvnm.vimusic.models
import androidx.compose.runtime.Immutable
import androidx.room.Entity
import androidx.room.PrimaryKey
@Immutable
@Entity
data class Song(
@PrimaryKey val id: String,

View file

@ -1,9 +1,11 @@
package it.vfsfitvnm.vimusic.models
import androidx.compose.runtime.Immutable
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.ForeignKey
@Immutable
@Entity(
primaryKeys = ["songId", "artistId"],
foreignKeys = [

View file

@ -1,9 +1,11 @@
package it.vfsfitvnm.vimusic.models
import androidx.compose.runtime.Immutable
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.ForeignKey
@Immutable
@Entity(
primaryKeys = ["songId", "playlistId"],
foreignKeys = [

View file

@ -1,8 +1,10 @@
package it.vfsfitvnm.vimusic.models
import androidx.compose.runtime.Immutable
import androidx.room.ColumnInfo
import androidx.room.DatabaseView
@Immutable
@DatabaseView("SELECT * FROM SongPlaylistMap ORDER BY position")
data class SortedSongPlaylistMap(
@ColumnInfo(index = true) val songId: String,