rcdbquery/src/main/kotlin/de/pheerai/rcdbquery/dataMappings/StartsWith.kt

25 lines
744 B
Kotlin

@file:Suppress("unused")
package de.pheerai.rcdbquery.dataMappings
import de.pheerai.rcdbquery.dsl.MultiParamsBuilder
class StartsWith(override val paramValue: String) : RcdbParamOption<String> {
override val prettyName = "Starts with"
override val fullName = "Name starting with term"
companion object {
const val staticParamName = "nl"
}
}
fun MultiParamsBuilder.startsWith(term: String) = if (StartsWith.staticParamName !in this.keys()) {
also { this[StartsWith.staticParamName] = listOf(StartsWith(term)) }
} else {
error(
"""Only one starts with term must ever be set
| Old term: ${this[StartsWith.staticParamName]!![0].paramValue}
| New term: $term""".trimMargin()
)
}