25 lines
752 B
Kotlin
25 lines
752 B
Kotlin
@file:Suppress("unused")
|
|
|
|
package de.pheerai.rcdbquery.dataMappings
|
|
|
|
import de.pheerai.rcdbquery.dsl.RcdbQueryParamsBuilder
|
|
|
|
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 RcdbQueryParamsBuilder.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()
|
|
)
|
|
}
|