rcdbquery/src/main/kotlin/de/pheerai/rcdbquery/dataMappings/StartsWith.kt
Oliver Rümpelein d8412c32f2 Add more search types:
- Classification
 - Status
 - Make some `order` params invisible for `all` params
 - Solved some order types
2020-04-30 16:30:16 +02:00

29 lines
803 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()) {
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()
)
}
}