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

@@ -30,7 +30,7 @@ object Avatars {
A210("A210", 0xFF5C5C5C.toInt());
fun deserialize(code: String): ForegroundColor {
return values().find { it.code == code } ?: throw IllegalArgumentException()
return entries.find { it.code == code } ?: throw IllegalArgumentException()
}
fun serialize(): String = code
@@ -39,7 +39,7 @@ object Avatars {
/**
* Mapping which associates color codes to ColorPair objects containing background and foreground colors.
*/
val colorMap: Map<String, ColorPair> = ForegroundColor.values().map {
val colorMap: Map<String, ColorPair> = ForegroundColor.entries.map {
ColorPair(AvatarColor.deserialize(it.serialize()), it)
}.associateBy {
it.code
@@ -134,7 +134,7 @@ object Avatars {
@JvmStatic
fun getForegroundColor(avatarColor: AvatarColor): ForegroundColor {
return ForegroundColor.values().firstOrNull { it.serialize() == avatarColor.serialize() } ?: ForegroundColor.A210
return ForegroundColor.entries.firstOrNull { it.serialize() == avatarColor.serialize() } ?: ForegroundColor.A210
}
data class DefaultAvatar(