2020-04-26 14:39:57 +02:00
|
|
|
@file:Suppress("unused")
|
|
|
|
|
|
|
|
package de.pheerai.rcdbquery.dataMappings
|
|
|
|
|
|
|
|
import de.pheerai.rcdbquery.dsl.RcdbQueryParamsBuilder
|
|
|
|
|
2020-04-30 16:30:16 +02:00
|
|
|
class StartsWith(override val paramValue: String) : RcdbParamOption<String> {
|
2020-04-26 14:39:57 +02:00
|
|
|
override val prettyName = "Starts with"
|
|
|
|
override val fullName = "Name starting with term"
|
2020-04-30 16:30:16 +02:00
|
|
|
|
2020-04-26 14:39:57 +02:00
|
|
|
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()
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|