Skip to content

Commit de002e4

Browse files
committed
rename TuneableTrackAttribute enums to camel case
1 parent b65d7cf commit de002e4

File tree

2 files changed

+39
-39
lines changed

2 files changed

+39
-39
lines changed

src/commonMain/kotlin/com.adamratzman.spotify/endpoints/public/BrowseApi.kt

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ import com.adamratzman.spotify.models.serialization.toObject
2525
import com.adamratzman.spotify.models.serialization.toPagingObject
2626
import com.adamratzman.spotify.utils.Market
2727
import com.adamratzman.spotify.utils.formatDate
28-
import kotlin.reflect.KClass
2928
import kotlinx.serialization.list
3029
import kotlinx.serialization.serializer
30+
import kotlin.reflect.KClass
3131

3232
@Deprecated("Endpoint name has been updated for kotlin convention consistency", ReplaceWith("BrowseApi"))
3333
typealias BrowseAPI = BrowseApi
@@ -325,33 +325,33 @@ sealed class TuneableTrackAttribute<T : Number>(
325325
val integerOnly: Boolean,
326326
val min: T?,
327327
val max: T?,
328-
val tClazz: KClass<T>
328+
internal val tClazz: KClass<T>
329329
) {
330330
/**
331331
* A confidence measure from 0.0 to 1.0 of whether the track is acoustic.
332332
* 1.0 represents high confidence the track is acoustic.
333333
*/
334-
object ACOUSTICNESS : TuneableTrackAttribute<Float>("acousticness", false, 0f, 1f, Float::class)
334+
object Acousticness : TuneableTrackAttribute<Float>("acousticness", false, 0f, 1f, Float::class)
335335

336336
/**
337337
* Danceability describes how suitable a track is for dancing based on a combination of musical
338338
* elements including tempo, rhythm stability, beat strength, and overall regularity. A value of 0.0 is
339339
* least danceable and 1.0 is most danceable.
340340
*/
341-
object DANCEABILITY : TuneableTrackAttribute<Float>("danceability", false, 0f, 1f, Float::class)
341+
object Danceability : TuneableTrackAttribute<Float>("danceability", false, 0f, 1f, Float::class)
342342

343343
/**
344344
* The duration of the track in milliseconds.
345345
*/
346-
object DURATION_IN_MILLISECONDS : TuneableTrackAttribute<Int>("duration_ms", true, 0, null, Int::class)
346+
object DurationInMilliseconds : TuneableTrackAttribute<Int>("duration_ms", true, 0, null, Int::class)
347347

348348
/**
349349
* Energy is a measure from 0.0 to 1.0 and represents a perceptual measure of intensity and activity.
350350
* Typically, energetic tracks feel fast, loud, and noisy. For example, death metal has high energy,
351351
* while a Bach prelude scores low on the scale. Perceptual features contributing to this attribute
352352
* include dynamic range, perceived loudness, timbre, onset rate, and general entropy.
353353
*/
354-
object ENERGY : TuneableTrackAttribute<Float>("energy", false, 0f, 1f, Float::class)
354+
object Energy : TuneableTrackAttribute<Float>("energy", false, 0f, 1f, Float::class)
355355

356356
/**
357357
* Predicts whether a track contains no vocals. “Ooh” and “aah” sounds are treated as
@@ -360,34 +360,34 @@ sealed class TuneableTrackAttribute<T : Number>(
360360
* no vocal content. Values above 0.5 are intended to represent instrumental tracks, but
361361
* confidence is higher as the value approaches 1.0.
362362
*/
363-
object INSTRUMENTALNESS : TuneableTrackAttribute<Float>("instrumentalness", false, 0f, 1f, Float::class)
363+
object Instrumentalness : TuneableTrackAttribute<Float>("instrumentalness", false, 0f, 1f, Float::class)
364364

365365
/**
366366
* The key the track is in. Integers map to pitches using standard Pitch Class notation.
367367
* E.g. 0 = C, 1 = C♯/D♭, 2 = D, and so on.
368368
*/
369-
object KEY : TuneableTrackAttribute<Int>("key", true, 0, 11, Int::class)
369+
object Key : TuneableTrackAttribute<Int>("key", true, 0, 11, Int::class)
370370

371371
/**
372372
* Detects the presence of an audience in the recording. Higher liveness values represent an increased
373373
* probability that the track was performed live. A value above 0.8 provides strong likelihood
374374
* that the track is live.
375375
*/
376-
object LIVENESS : TuneableTrackAttribute<Float>("liveness", false, 0f, 1f, Float::class)
376+
object Liveness : TuneableTrackAttribute<Float>("liveness", false, 0f, 1f, Float::class)
377377

378378
/**
379379
* The overall loudness of a track in decibels (dB). Loudness values are averaged across the
380380
* entire track and are useful for comparing relative loudness of tracks. Loudness is the
381381
* quality of a sound that is the primary psychological correlate of physical strength (amplitude).
382382
* Values typically range between -60 and 0 db.
383383
*/
384-
object LOUDNESS : TuneableTrackAttribute<Float>("loudness", false, null, null, Float::class)
384+
object Loudness : TuneableTrackAttribute<Float>("loudness", false, null, null, Float::class)
385385

386386
/**
387387
* Mode indicates the modality (major or minor) of a track, the type of scale from which its
388388
* melodic content is derived. Major is represented by 1 and minor is 0.
389389
*/
390-
object MODE : TuneableTrackAttribute<Int>("mode", true, 0, 1, Int::class)
390+
object Mode : TuneableTrackAttribute<Int>("mode", true, 0, 1, Int::class)
391391

392392
/**
393393
* The popularity of the track. The value will be between 0 and 100, with 100 being the most popular.
@@ -396,7 +396,7 @@ sealed class TuneableTrackAttribute<T : Number>(
396396
* the market parameter, it is expected to find relinked tracks with popularities that do not match
397397
* min_*, max_*and target_* popularities. These relinked tracks are accurate replacements for unplayable tracks with the expected popularity scores. Original, non-relinked tracks are available via the linked_from attribute of the relinked track response.
398398
*/
399-
object POPULARITY : TuneableTrackAttribute<Int>("popularity", true, 0, 100, Int::class)
399+
object Popularity : TuneableTrackAttribute<Int>("popularity", true, 0, 100, Int::class)
400400

401401
/**
402402
* Speechiness detects the presence of spoken words in a track. The more exclusively speech-like the
@@ -406,28 +406,28 @@ sealed class TuneableTrackAttribute<T : Number>(
406406
* such cases as rap music. Values below 0.33 most likely represent music and other non-speech-like
407407
* tracks.
408408
*/
409-
object SPEECHINESS : TuneableTrackAttribute<Float>("speechiness", false, 0f, 1f, Float::class)
409+
object Speechiness : TuneableTrackAttribute<Float>("speechiness", false, 0f, 1f, Float::class)
410410

411411
/**
412412
* The overall estimated tempo of a track in beats per minute (BPM). In musical terminology, tempo is the
413413
* speed or pace of a given piece and derives directly from the average beat duration.
414414
*/
415-
object TEMPO : TuneableTrackAttribute<Float>("tempo", false, 0f, null, Float::class)
415+
object Tempo : TuneableTrackAttribute<Float>("tempo", false, 0f, null, Float::class)
416416

417417
/**
418418
* An estimated overall time signature of a track. The time signature (meter)
419419
* is a notational convention to specify how many beats are in each bar (or measure).
420420
* The time signature ranges from 3 to 7 indicating time signatures of 3/4, to 7/4.
421421
* A value of -1 may indicate no time signature, while a value of 1 indicates a rather complex or changing time signature.
422422
*/
423-
object TIME_SIGNATURE : TuneableTrackAttribute<Int>("time_signature", true, -1, 7, Int::class)
423+
object TimeSignature : TuneableTrackAttribute<Int>("time_signature", true, -1, 7, Int::class)
424424

425425
/**
426426
* A measure from 0.0 to 1.0 describing the musical positiveness conveyed by a track. Tracks with high
427427
* valence sound more positive (e.g. happy, cheerful, euphoric), while tracks with low valence
428428
* sound more negative (e.g. sad, depressed, angry).
429429
*/
430-
object VALENCE : TuneableTrackAttribute<Float>("valence", false, 0f, 1f, Float::class)
430+
object Valence : TuneableTrackAttribute<Float>("valence", false, 0f, 1f, Float::class)
431431

432432
override fun toString() = attribute
433433

@@ -446,20 +446,20 @@ sealed class TuneableTrackAttribute<T : Number>(
446446

447447
companion object {
448448
fun values() = listOf(
449-
ACOUSTICNESS,
450-
DANCEABILITY,
451-
DURATION_IN_MILLISECONDS,
452-
ENERGY,
453-
INSTRUMENTALNESS,
454-
KEY,
455-
LIVENESS,
456-
LOUDNESS,
457-
MODE,
458-
POPULARITY,
459-
SPEECHINESS,
460-
TEMPO,
461-
TIME_SIGNATURE,
462-
VALENCE
449+
Acousticness,
450+
Danceability,
451+
DurationInMilliseconds,
452+
Energy,
453+
Instrumentalness,
454+
Key,
455+
Liveness,
456+
Loudness,
457+
Mode,
458+
Popularity,
459+
Speechiness,
460+
Tempo,
461+
TimeSignature,
462+
Valence
463463
)
464464
}
465465
}

src/commonTest/kotlin/com.adamratzman/spotify/public/BrowseAPITest.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class BrowseAPITest : Spek({
115115
assertFailsWith<IllegalArgumentException> {
116116
b.getTrackRecommendations(
117117
targetAttributes = listOf(
118-
TuneableTrackAttribute.ACOUSTICNESS.asTrackAttribute(
118+
TuneableTrackAttribute.Acousticness.asTrackAttribute(
119119
3f
120120
)
121121
)
@@ -124,8 +124,8 @@ class BrowseAPITest : Spek({
124124
assertTrue(
125125
b.getTrackRecommendations(
126126
targetAttributes = listOf(
127-
TuneableTrackAttribute.ACOUSTICNESS.asTrackAttribute(1f),
128-
TuneableTrackAttribute.DANCEABILITY.asTrackAttribute(0.5f)
127+
TuneableTrackAttribute.Acousticness.asTrackAttribute(1f),
128+
TuneableTrackAttribute.Danceability.asTrackAttribute(0.5f)
129129
),
130130
seedGenres = listOf("pop")
131131
).complete().tracks.isNotEmpty()
@@ -135,7 +135,7 @@ class BrowseAPITest : Spek({
135135
assertFailsWith<IllegalArgumentException> {
136136
b.getTrackRecommendations(
137137
minAttributes = listOf(
138-
TuneableTrackAttribute.ACOUSTICNESS.asTrackAttribute(
138+
TuneableTrackAttribute.Acousticness.asTrackAttribute(
139139
3f
140140
)
141141
)
@@ -144,8 +144,8 @@ class BrowseAPITest : Spek({
144144
assertTrue(
145145
b.getTrackRecommendations(
146146
minAttributes = listOf(
147-
TuneableTrackAttribute.ACOUSTICNESS.asTrackAttribute(0.5f),
148-
TuneableTrackAttribute.DANCEABILITY.asTrackAttribute(0.5f)
147+
TuneableTrackAttribute.Acousticness.asTrackAttribute(0.5f),
148+
TuneableTrackAttribute.Danceability.asTrackAttribute(0.5f)
149149
),
150150
seedGenres = listOf("pop")
151151
).complete().tracks.isNotEmpty()
@@ -155,7 +155,7 @@ class BrowseAPITest : Spek({
155155
assertFailsWith<SpotifyException.BadRequestException> {
156156
b.getTrackRecommendations(
157157
maxAttributes = listOf(
158-
TuneableTrackAttribute.SPEECHINESS.asTrackAttribute(
158+
TuneableTrackAttribute.Speechiness.asTrackAttribute(
159159
0.9f
160160
)
161161
)
@@ -164,8 +164,8 @@ class BrowseAPITest : Spek({
164164
assertTrue(
165165
b.getTrackRecommendations(
166166
maxAttributes = listOf(
167-
TuneableTrackAttribute.ACOUSTICNESS.asTrackAttribute(0.9f),
168-
TuneableTrackAttribute.DANCEABILITY.asTrackAttribute(0.9f)
167+
TuneableTrackAttribute.Acousticness.asTrackAttribute(0.9f),
168+
TuneableTrackAttribute.Danceability.asTrackAttribute(0.9f)
169169
),
170170
seedGenres = listOf("pop")
171171
).complete().tracks.isNotEmpty()

0 commit comments

Comments
 (0)