@@ -56,10 +56,10 @@ fun Preset.toRoomDto(gson: Gson): PresetDto {
56
56
data class PresetV2 (
57
57
val id : String ,
58
58
val name : String ,
59
- val playerStates : List <PlayerState >,
60
- ) : Serializable {
59
+ val playerStates : Array <PlayerState >,
60
+ ) {
61
61
62
- constructor (name: String , playerStates: List <PlayerState >)
62
+ constructor (name: String , playerStates: Array <PlayerState >)
63
63
: this (UUID .randomUUID().toString(), name, playerStates)
64
64
65
65
/* *
@@ -70,13 +70,27 @@ data class PresetV2(
70
70
return Preset (id = id, name = name, soundStates = soundsV3)
71
71
}
72
72
73
- companion object {
74
- val GSON_TYPE_PLAYER_STATES : Type = TypeToken
75
- .getParameterized(List ::class .java, PlayerState ::class .java)
76
- .type
73
+ override fun equals (other : Any? ): Boolean {
74
+ if (this == = other) return true
75
+ if (javaClass != other?.javaClass) return false
76
+
77
+ other as PresetV2
78
+
79
+ if (id != other.id) return false
80
+ if (name != other.name) return false
81
+ if (! playerStates.contentEquals(other.playerStates)) return false
82
+
83
+ return true
84
+ }
85
+
86
+ override fun hashCode (): Int {
87
+ var result = id.hashCode()
88
+ result = 31 * result + name.hashCode()
89
+ result = 31 * result + playerStates.contentHashCode()
90
+ return result
77
91
}
78
92
79
- data class PlayerState (val soundId : String , val volume : Int ) : Serializable
93
+ data class PlayerState (val soundId : String , val volume : Int )
80
94
}
81
95
82
96
/* *
@@ -95,7 +109,7 @@ data class PresetV2(
95
109
data class PresetV1 (
96
110
val id : String ,
97
111
val name : String ,
98
- val playerStates : List <PlayerState >,
112
+ val playerStates : Array <PlayerState >,
99
113
) {
100
114
101
115
/* *
@@ -113,7 +127,27 @@ data class PresetV1(
113
127
}
114
128
115
129
playerStatesV2.sortBy { it.soundId }
116
- return PresetV2 (id = id, name = name, playerStates = playerStatesV2)
130
+ return PresetV2 (id = id, name = name, playerStates = playerStatesV2.toTypedArray())
131
+ }
132
+
133
+ override fun equals (other : Any? ): Boolean {
134
+ if (this == = other) return true
135
+ if (javaClass != other?.javaClass) return false
136
+
137
+ other as PresetV1
138
+
139
+ if (id != other.id) return false
140
+ if (name != other.name) return false
141
+ if (! playerStates.contentEquals(other.playerStates)) return false
142
+
143
+ return true
144
+ }
145
+
146
+ override fun hashCode (): Int {
147
+ var result = id.hashCode()
148
+ result = 31 * result + name.hashCode()
149
+ result = 31 * result + playerStates.contentHashCode()
150
+ return result
117
151
}
118
152
119
153
companion object {
@@ -176,7 +210,7 @@ data class PresetV1(
176
210
*/
177
211
data class PresetV0 (
178
212
@SerializedName(" a" ) val name : String ,
179
- @SerializedName(" b" ) val playerStates : List <PlayerState >,
213
+ @SerializedName(" b" ) val playerStates : Array <PlayerState >,
180
214
) {
181
215
182
216
/* *
@@ -194,10 +228,29 @@ data class PresetV0(
194
228
volume = (it.volume * 25 ).roundToInt(),
195
229
timePeriod = it.timePeriod + 30 ,
196
230
)
197
- },
231
+ }
232
+ .toTypedArray(),
198
233
)
199
234
}
200
235
236
+ override fun equals (other : Any? ): Boolean {
237
+ if (this == = other) return true
238
+ if (javaClass != other?.javaClass) return false
239
+
240
+ other as PresetV0
241
+
242
+ if (name != other.name) return false
243
+ if (! playerStates.contentEquals(other.playerStates)) return false
244
+
245
+ return true
246
+ }
247
+
248
+ override fun hashCode (): Int {
249
+ var result = name.hashCode()
250
+ result = 31 * result + playerStates.contentHashCode()
251
+ return result
252
+ }
253
+
201
254
data class PlayerState (
202
255
@SerializedName(" a" ) val soundKey : String ,
203
256
@SerializedName(" b" ) val volume : Double ,
0 commit comments