Move from enum.values() to enum.entries.

Resolves #13767
This commit is contained in:
Grzegorz Bobryk
2024-11-03 16:18:10 +01:00
committed by Greyson Parrelli
parent be92b3cf0a
commit cafbf48783
60 changed files with 95 additions and 95 deletions

View File

@@ -2793,7 +2793,7 @@ class AttachmentTable(
companion object {
fun deserialize(value: Int): ThumbnailRestoreState {
return values().firstOrNull { it.value == value } ?: NONE
return entries.firstOrNull { it.value == value } ?: NONE
}
}
}
@@ -2833,7 +2833,7 @@ class AttachmentTable(
companion object {
fun deserialize(value: Int): ArchiveTransferState {
return values().firstOrNull { it.value == value } ?: NONE
return entries.firstOrNull { it.value == value } ?: NONE
}
}
}

View File

@@ -1631,7 +1631,7 @@ class CallTable(context: Context, databaseHelper: SignalDatabase) : DatabaseTabl
}
override fun deserialize(data: Int): ReadState {
return ReadState.values().first { it.code == data }
return entries.first { it.code == data }
}
}
}
@@ -1716,7 +1716,7 @@ class CallTable(context: Context, databaseHelper: SignalDatabase) : DatabaseTabl
override fun serialize(data: Event): Int = data.code
override fun deserialize(data: Int): Event {
return values().firstOrNull {
return entries.firstOrNull {
it.code == data
} ?: throw IllegalArgumentException("Unknown event $data")
}

View File

@@ -162,6 +162,6 @@ class InAppPaymentSubscriberTable(
object TypeSerializer : Serializer<InAppPaymentSubscriberRecord.Type, Int> {
override fun serialize(data: InAppPaymentSubscriberRecord.Type): Int = data.code
override fun deserialize(input: Int): InAppPaymentSubscriberRecord.Type = InAppPaymentSubscriberRecord.Type.values().first { it.code == input }
override fun deserialize(input: Int): InAppPaymentSubscriberRecord.Type = InAppPaymentSubscriberRecord.Type.entries.first { it.code == input }
}
}

View File

@@ -414,7 +414,7 @@ class InAppPaymentTable(context: Context, databaseHelper: SignalDatabase) : Data
companion object : Serializer<State, Int> {
override fun serialize(data: State): Int = data.code
override fun deserialize(input: Int): State = State.values().first { it.code == input }
override fun deserialize(input: Int): State = entries.first { it.code == input }
}
}
}

View File

@@ -4714,7 +4714,7 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
companion object {
fun fromId(id: Int): VibrateState {
return values()[id]
return entries[id]
}
fun fromBoolean(enabled: Boolean): VibrateState {
@@ -4730,7 +4730,7 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
companion object {
fun fromId(id: Int): RegisteredState {
return values()[id]
return entries[id]
}
}
}
@@ -4743,7 +4743,7 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
companion object {
fun fromMode(mode: Int): SealedSenderAccessMode {
return values()[mode]
return entries[mode]
}
}
}
@@ -4759,7 +4759,7 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
companion object {
fun fromId(id: Int): InsightsBannerTier {
return values()[id]
return entries[id]
}
}
}
@@ -4774,7 +4774,7 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
companion object {
fun fromId(id: Int): RecipientType {
return values()[id]
return entries[id]
}
}
}
@@ -4785,7 +4785,7 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
companion object {
fun fromId(id: Int): MentionSetting {
return values()[id]
return entries[id]
}
}
}
@@ -4800,7 +4800,7 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
companion object {
fun fromId(id: Int): PhoneNumberSharingState {
return values()[id]
return entries[id]
}
}
}
@@ -4812,7 +4812,7 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
companion object {
fun fromId(id: Int): PhoneNumberDiscoverableState {
return PhoneNumberDiscoverableState.values()[id]
return entries[id]
}
}
}

View File

@@ -2352,7 +2352,7 @@ class ThreadTable(context: Context, databaseHelper: SignalDatabase) : DatabaseTa
companion object {
fun deserialize(value: Int): ReadStatus {
for (status in values()) {
for (status in entries) {
if (status.value == value) {
return status
}

View File

@@ -55,7 +55,7 @@ data class RemoteMegaphoneRecord(
companion object {
fun from(id: String?): ActionId? {
return values().firstOrNull { it.id == id }
return entries.firstOrNull { it.id == id }
}
}
}