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 package it.vfsfitvnm.vimusic.models
import androidx.compose.runtime.Immutable
import androidx.room.Entity import androidx.room.Entity
import androidx.room.PrimaryKey import androidx.room.PrimaryKey
@Immutable
@Entity @Entity
data class Album( data class Album(
@PrimaryKey val id: String, @PrimaryKey val id: String,

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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