Compare commits
1 commit
6986ab5a1c
...
a94867bb1b
Author | SHA1 | Date | |
---|---|---|---|
a94867bb1b |
1 changed files with 5 additions and 6 deletions
|
@ -8,13 +8,12 @@ data class ActivationCode(
|
|||
) {
|
||||
companion object {
|
||||
fun fromString(input: String): ActivationCode {
|
||||
val components = input.removePrefix("LPA:").split('$')
|
||||
.map(String::trim).map { it.ifBlank { null } }
|
||||
if (components.size < 2 || components[0] != "1" || components[1] == null) {
|
||||
throw IllegalStateException("Invalid activation code format")
|
||||
}
|
||||
check(input.startsWith("LPA:", ignoreCase = true)) { "Invalid activation code format" }
|
||||
val components = input.drop(4).split('$').map(String::trim).map { it.ifBlank { null } }
|
||||
check(components.size >= 2) { "Invalid activation code format" }
|
||||
check(components[0] == "1") { "Invalid activation code version" }
|
||||
return ActivationCode(
|
||||
components[1]!!,
|
||||
checkNotNull(components[1]) { "Invalid SM-DP+ address" },
|
||||
components.getOrNull(2),
|
||||
components.getOrNull(3),
|
||||
components.getOrNull(4) == "1",
|
||||
|
|
Loading…
Add table
Reference in a new issue