-
Notifications
You must be signed in to change notification settings - Fork 92
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
Showing
3 changed files
with
16 additions
and
16 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
15 changes: 7 additions & 8 deletions
15
...lin/org/worldcubeassociation/tnoodle/server/webscrambles/wcif/model/RegistrationStatus.kt
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 |
---|---|---|
@@ -1,19 +1,18 @@ | ||
package org.worldcubeassociation.tnoodle.server.webscrambles.wcif.model | ||
|
||
import org.worldcubeassociation.tnoodle.server.serial.SingletonStringEncoder | ||
import org.worldcubeassociation.tnoodle.server.webscrambles.exceptions.BadWcifParameterException | ||
|
||
enum class RegistrationStatus { | ||
ACCEPTED, | ||
PENDING, | ||
DELETED; | ||
|
||
val wcaString | ||
get() = name.toLowerCase() | ||
enum class RegistrationStatus(val wcaString: String) { | ||
ACCEPTED("accepted"), | ||
PENDING("pending"), | ||
DELETED("deleted"); | ||
|
||
companion object : SingletonStringEncoder<RegistrationStatus>("RegistrationStatus") { | ||
fun fromWCAString(wcaString: String) = values().find { it.wcaString == wcaString } | ||
|
||
override fun encodeInstance(instance: RegistrationStatus) = instance.wcaString | ||
override fun makeInstance(deserialized: String) = fromWCAString(deserialized)!! | ||
override fun makeInstance(deserialized: String) = fromWCAString(deserialized) | ||
?: BadWcifParameterException.error("Unknown WCIF spec RegistrationStatus: '$deserialized'. Valid types: ${values().map { it.wcaString }}") | ||
} | ||
} |
13 changes: 6 additions & 7 deletions
13
...main/kotlin/org/worldcubeassociation/tnoodle/server/webscrambles/wcif/model/ResultType.kt
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 |
---|---|---|
@@ -1,18 +1,17 @@ | ||
package org.worldcubeassociation.tnoodle.server.webscrambles.wcif.model | ||
|
||
import org.worldcubeassociation.tnoodle.server.serial.SingletonStringEncoder | ||
import org.worldcubeassociation.tnoodle.server.webscrambles.exceptions.BadWcifParameterException | ||
|
||
enum class ResultType { | ||
SINGLE, | ||
AVERAGE; | ||
|
||
val wcaString | ||
get() = this.name.toLowerCase() | ||
enum class ResultType(val wcaString: String) { | ||
SINGLE("single"), | ||
AVERAGE("average"); | ||
|
||
companion object : SingletonStringEncoder<ResultType>("ResultType") { | ||
fun fromWCAString(wcaString: String) = values().find { it.wcaString == wcaString } | ||
|
||
override fun encodeInstance(instance: ResultType) = instance.wcaString | ||
override fun makeInstance(deserialized: String) = fromWCAString(deserialized)!! | ||
override fun makeInstance(deserialized: String) = fromWCAString(deserialized) | ||
?: BadWcifParameterException.error("Unknown WCIF spec ResultType: '$deserialized'. Valid types: ${values().map { it.wcaString }}") | ||
} | ||
} |