KStarbound/src/main/kotlin/ru/dbotthepony/kstarbound/util/FullJsonPath.kt
2022-12-30 18:49:03 +07:00

20 lines
401 B
Kotlin

package ru.dbotthepony.kstarbound.util
class FullJsonPath(val fullPath: String) {
init {
val delimers = fullPath.count { it == ':' }
require(delimers < 2) { "Invalid path: $fullPath" }
}
val path = fullPath.substringBefore(':')
val subpath: JsonPath
init {
if (path.any { it == ':' }) {
subpath = JsonPath(fullPath.substringAfter(':'))
} else {
subpath = JsonPath.EMPTY
}
}
}