forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0bd084b
commit dad0a95
Showing
2 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import java.{lang => jl} | ||
|
||
final class ConfigValueType private (val name: String, val ordinal: Int) | ||
|
||
object ConfigValueType: | ||
final val OBJECT = new ConfigValueType("OBJECT", 0) | ||
final val LIST = new ConfigValueType("LIST", 1) | ||
final val NUMBER = new ConfigValueType("NUMBER", 2) | ||
final val BOOLEAN = new ConfigValueType("BOOLEAN", 3) | ||
final val NULL = new ConfigValueType("NULL", 4) | ||
final val STRING = new ConfigValueType("STRING", 5) | ||
|
||
final val _values: Array[ConfigValueType] = | ||
Array(OBJECT, LIST, NUMBER, BOOLEAN, NULL, STRING) | ||
|
||
def values: Array[ConfigValueType] = _values.clone() | ||
|
||
def valueOf(name: String): ConfigValueType = | ||
_values.find(_.name == name).getOrElse { | ||
throw new IllegalArgumentException( | ||
"No enum const ConfigValueType." + name | ||
) | ||
} | ||
|
||
object Usage: | ||
val c = ConfigValueType.valueOf("LIST") |