Skip to content

Commit fd69956

Browse files
committed
set nullable model fields' default value to null
1 parent 45c4499 commit fd69956

File tree

7 files changed

+27
-27
lines changed

7 files changed

+27
-27
lines changed

src/commonMain/kotlin/com.adamratzman.spotify/models/Browse.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ data class SpotifyCategory(
3535
*/
3636
@Serializable
3737
data class RecommendationSeed(
38-
@SerialName("href") override val href: String?,
38+
@SerialName("href") override val href: String? = null,
3939
@SerialName("id") override val id: String,
4040

4141
val initialPoolSize: Int,
4242
val afterFilteringSize: Int,
43-
val afterRelinkingSize: Int?,
43+
val afterRelinkingSize: Int? = null,
4444
val type: String
4545
) : Identifiable(href, id)
4646

src/commonMain/kotlin/com.adamratzman.spotify/models/PagingObjects.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import com.adamratzman.spotify.http.SpotifyEndpoint
66
import com.adamratzman.spotify.models.serialization.toCursorBasedPagingObject
77
import com.adamratzman.spotify.models.serialization.toPagingObject
88
import com.adamratzman.spotify.utils.runBlocking
9-
import kotlin.reflect.KClass
109
import kotlinx.coroutines.Dispatchers
1110
import kotlinx.coroutines.ExperimentalCoroutinesApi
1211
import kotlinx.coroutines.flow.Flow
@@ -18,6 +17,7 @@ import kotlinx.coroutines.flow.toList
1817
import kotlinx.serialization.SerialName
1918
import kotlinx.serialization.Serializable
2019
import kotlinx.serialization.Transient
20+
import kotlin.reflect.KClass
2121

2222
/*
2323
Types used in PagingObjects and CursorBasedPagingObjects:
@@ -62,9 +62,9 @@ class PagingObject<T : Any>(
6262
override val href: String,
6363
override val items: List<T>,
6464
override val limit: Int,
65-
override val next: String?,
65+
override val next: String? = null,
6666
override val offset: Int,
67-
override val previous: String?,
67+
override val previous: String? = null,
6868
override val total: Int = 0
6969
) : AbstractPagingObject<T>(href, items, limit, next, offset, previous, total) {
7070
@Suppress("UNCHECKED_CAST")
@@ -135,7 +135,7 @@ class CursorBasedPagingObject<T : Any>(
135135
override val href: String,
136136
override val items: List<T>,
137137
override val limit: Int,
138-
override val next: String?,
138+
override val next: String? = null,
139139
@SerialName("cursors") val cursor: Cursor,
140140
override val total: Int = 0
141141
) : AbstractPagingObject<T>(href, items, limit, next, 0, null, total) {

src/commonMain/kotlin/com.adamratzman.spotify/models/Player.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ data class PlayHistoryContext(
4040
data class PlayHistory(
4141
val track: SimpleTrack,
4242
@SerialName("played_at") val playedAt: String,
43-
val context: PlayHistoryContext?
43+
val context: PlayHistoryContext? = null
4444
)
4545

4646
/**
@@ -56,7 +56,7 @@ data class PlayHistory(
5656
*/
5757
@Serializable
5858
data class Device(
59-
@SerialName("id") override val id: String?,
59+
@SerialName("id") override val id: String? = null,
6060

6161
@SerialName("is_active") val isActive: Boolean,
6262
@SerialName("is_private_session") val isPrivateSession: Boolean,
@@ -107,9 +107,9 @@ enum class DeviceType(val identifier: String) {
107107
data class CurrentlyPlayingContext(
108108
val timestamp: Long,
109109
val device: Device,
110-
@SerialName("progress_ms") val progressMs: Int?,
110+
@SerialName("progress_ms") val progressMs: Int? = null,
111111
@SerialName("is_playing") val isPlaying: Boolean,
112-
@SerialName("item") val track: Track?,
112+
@SerialName("item") val track: Track? = null,
113113
@SerialName("shuffle_state") val shuffleState: Boolean,
114114
@SerialName("repeat_state") val repeatStateString: String,
115115
val context: Context
@@ -143,9 +143,9 @@ enum class RepeatState(val identifier: String) : ResultEnum {
143143
*/
144144
@Serializable
145145
data class CurrentlyPlayingObject(
146-
val context: PlayHistoryContext?,
146+
val context: PlayHistoryContext? = null,
147147
val timestamp: Long,
148-
@SerialName("progress_ms") val progressMs: Int?,
148+
@SerialName("progress_ms") val progressMs: Int? = null,
149149
@SerialName("is_playing") val isPlaying: Boolean,
150150
@SerialName("item") val track: Track,
151151
@SerialName("currently_playing_type") private val currentlyPlayingTypeString: String,

src/commonMain/kotlin/com.adamratzman.spotify/models/Playlist.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ data class SimplePlaylist(
4040
val collaborative: Boolean,
4141
val images: List<SpotifyImage>,
4242
val name: String,
43-
val description: String?,
43+
val description: String? = null,
4444
val owner: SpotifyPublicUser,
4545
@SerialName("primary_color") val primaryColor: String? = null,
4646
val public: Boolean? = null,
@@ -75,9 +75,9 @@ data class SimplePlaylist(
7575
@Serializable
7676
data class PlaylistTrack(
7777
@SerialName("primary_color") val primaryColor: String? = null,
78-
@SerialName("added_at") val addedAt: String?,
79-
@SerialName("added_by") val addedBy: SpotifyPublicUser?,
80-
@SerialName("is_local") val isLocal: Boolean?,
78+
@SerialName("added_at") val addedAt: String? = null,
79+
@SerialName("added_by") val addedBy: SpotifyPublicUser? = null,
80+
@SerialName("is_local") val isLocal: Boolean? = null,
8181
val track: Track,
8282
@SerialName("video_thumbnail") val videoThumbnail: VideoThumbnail? = null
8383
)
@@ -112,7 +112,7 @@ data class Playlist(
112112
@SerialName("uri") private val uriString: String,
113113

114114
val collaborative: Boolean,
115-
val description: String?,
115+
val description: String? = null,
116116
val followers: Followers,
117117
@SerialName("primary_color") val primaryColor: String? = null,
118118
val images: List<SpotifyImage>,

src/commonMain/kotlin/com.adamratzman.spotify/models/Search.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import kotlinx.serialization.Serializable
55

66
@Serializable
77
class SpotifySearchResult(
8-
val albums: PagingObject<SimpleAlbum>?,
9-
val artists: PagingObject<Artist>?,
10-
val playlists: PagingObject<SimplePlaylist>?,
11-
val tracks: PagingObject<Track>?
8+
val albums: PagingObject<SimpleAlbum>? = null,
9+
val artists: PagingObject<Artist>? = null,
10+
val playlists: PagingObject<SimplePlaylist>? = null,
11+
val tracks: PagingObject<Track>? = null
1212
)

src/commonMain/kotlin/com.adamratzman.spotify/models/Track.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ data class SimpleTrack(
5252
@SerialName("is_playable") val isPlayable: Boolean = true,
5353
@SerialName("linked_from") private val linkedFrom: LinkedTrack? = null,
5454
val name: String,
55-
@SerialName("preview_url") val previewUrl: String?,
55+
@SerialName("preview_url") val previewUrl: String? = null,
5656
@SerialName("track_number") val trackNumber: Int,
5757
val type: String,
5858
@SerialName("is_local") val isLocal: Boolean? = null,
@@ -130,10 +130,10 @@ data class Track(
130130
@SerialName("linked_from") private val linked_from: LinkedTrack? = null,
131131
val name: String,
132132
val popularity: Int,
133-
@SerialName("preview_url") val previewUrl: String?,
133+
@SerialName("preview_url") val previewUrl: String? = null,
134134
@SerialName("track_number") val trackNumber: Int,
135135
val type: String,
136-
@SerialName("is_local") val isLocal: Boolean?,
136+
@SerialName("is_local") val isLocal: Boolean? = null,
137137
val restrictions: Restrictions? = null,
138138

139139
val episode: Boolean? = null,

src/commonMain/kotlin/com.adamratzman.spotify/models/Users.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ data class SpotifyUserInformation(
3737
val email: String? = null,
3838
val followers: Followers,
3939
val images: List<SpotifyImage>,
40-
val product: String?,
41-
@SerialName("explicit_content") val explicitContentSettings: ExplicitContentSettings?,
40+
val product: String? = null,
41+
@SerialName("explicit_content") val explicitContentSettings: ExplicitContentSettings? = null,
4242
val type: String
4343
) : CoreObject(href, id, UserUri(uriString), externalUrlsString) {
4444
override val uri: UserUri get() = super.uri as UserUri
@@ -79,7 +79,7 @@ data class SpotifyPublicUser(
7979
*/
8080
@Serializable
8181
data class Followers(
82-
val href: String?,
82+
val href: String? = null,
8383
@SerialName("total") val total: Int
8484
)
8585

0 commit comments

Comments
 (0)