Skip to content

Commit

Permalink
[Refactor] Change Enum.values() to Enum.entries.
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanghai committed Jan 6, 2024
1 parent b0cbbac commit e67e482
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ enum class Protocol(val scheme: String, val defaultPort: Int, val createClient:
FTPES("ftpes", FTPClient.DEFAULT_PORT, { FTPSClient(false) });

companion object {
val SCHEMES = values().map { it.scheme }
val SCHEMES = entries.map { it.scheme }

fun fromScheme(scheme: String): Protocol =
values().firstOrNull() { it.scheme == scheme } ?: throw IllegalArgumentException(scheme)
entries.firstOrNull { it.scheme == scheme } ?: throw IllegalArgumentException(scheme)
}
}

0 comments on commit e67e482

Please sign in to comment.