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

@@ -23,14 +23,14 @@ object AttachmentCreator : Parcelable.Creator<Attachment> {
@JvmStatic
fun writeSubclass(dest: Parcel, instance: Attachment) {
val subclass = Subclass.values().firstOrNull { it.clazz == instance::class.java } ?: error("Unexpected subtype ${instance::class.java.simpleName}")
val subclass = Subclass.entries.firstOrNull { it.clazz == instance::class.java } ?: error("Unexpected subtype ${instance::class.java.simpleName}")
dest.writeString(subclass.code)
}
override fun createFromParcel(source: Parcel): Attachment {
val rawCode = source.readString()!!
return when (Subclass.values().first { rawCode == it.code }) {
return when (Subclass.entries.first { rawCode == it.code }) {
Subclass.DATABASE -> DatabaseAttachment(source)
Subclass.POINTER -> PointerAttachment(source)
Subclass.TOMBSTONE -> TombstoneAttachment(source)

View File

@@ -37,7 +37,7 @@ enum class Cdn(private val value: Int) {
}
override fun deserialize(data: Int): Cdn {
return values().first { it.value == data }
return entries.first { it.value == data }
}
fun fromCdnNumber(cdnNumber: Int): Cdn {