Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#3 - values() call replaced by entries (kotlin 1.9) #10

Merged
merged 1 commit into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,21 @@ val FIXED_VALUES = FixedValues(
* Map containing all known tags. The key is the respective hex code as string in lowercase with leading prefix 0x
*/
val tagsByHexString = mutableMapOf<String, Tag>()
.apply { putAll(BatTag.values().associateBy { it.hex.lowercase() }) }
.apply { putAll(DBTag.values().associateBy { it.hex.lowercase() }) }
.apply { putAll(DCDCTag.values().associateBy { it.hex.lowercase() }) }
.apply { putAll(EMSTag.values().associateBy { it.hex.lowercase() }) }
.apply { putAll(EPTag.values().associateBy { it.hex.lowercase() }) }
.apply { putAll(FMSTag.values().associateBy { it.hex.lowercase() }) }
.apply { putAll(HATag.values().associateBy { it.hex.lowercase() }) }
.apply { putAll(InfoTag.values().associateBy { it.hex.lowercase() }) }
.apply { putAll(PMTag.values().associateBy { it.hex.lowercase() }) }
.apply { putAll(PVITag.values().associateBy { it.hex.lowercase() }) }
.apply { putAll(RSCPTag.values().associateBy { it.hex.lowercase() }) }
.apply { putAll(SRVTag.values().associateBy { it.hex.lowercase() }) }
.apply { putAll(SYSTag.values().associateBy { it.hex.lowercase() }) }
.apply { putAll(UMTag.values().associateBy { it.hex.lowercase() }) }
.apply { putAll(WBTag.values().associateBy { it.hex.lowercase() }) }
.apply { putAll(BatTag.entries.associateBy { it.hex.lowercase() }) }
.apply { putAll(DBTag.entries.associateBy { it.hex.lowercase() }) }
.apply { putAll(DCDCTag.entries.associateBy { it.hex.lowercase() }) }
.apply { putAll(EMSTag.entries.associateBy { it.hex.lowercase() }) }
.apply { putAll(EPTag.entries.associateBy { it.hex.lowercase() }) }
.apply { putAll(FMSTag.entries.associateBy { it.hex.lowercase() }) }
.apply { putAll(HATag.entries.associateBy { it.hex.lowercase() }) }
.apply { putAll(InfoTag.entries.associateBy { it.hex.lowercase() }) }
.apply { putAll(PMTag.entries.associateBy { it.hex.lowercase() }) }
.apply { putAll(PVITag.entries.associateBy { it.hex.lowercase() }) }
.apply { putAll(RSCPTag.entries.associateBy { it.hex.lowercase() }) }
.apply { putAll(SRVTag.entries.associateBy { it.hex.lowercase() }) }
.apply { putAll(SYSTag.entries.associateBy { it.hex.lowercase() }) }
.apply { putAll(UMTag.entries.associateBy { it.hex.lowercase() }) }
.apply { putAll(WBTag.entries.associateBy { it.hex.lowercase() }) }
.toMap()

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ enum class DataType(val code: Byte) {
* @since 2.0
*/
fun byCode(code: Byte) =
DataType.values()
entries
.find { it.code == code }
?: UNKNOWN

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ enum class Namespace(val code: Byte) {

companion object {
fun byCode(code: Byte) =
values()
entries
.find { it.code == code }
?: UNKNOWN

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ enum class ResultCode(val rscpCode: Int) {

companion object {
fun byRscpCode(code: Int): ResultCode =
values().find { it.rscpCode == code }?: UNKNOWN
entries.find { it.rscpCode == code }?: UNKNOWN

}
}