diff --git a/gradle.properties b/gradle.properties index 29e08e8..7fc6f1f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1 +1 @@ -kotlin.code.style=official \ No newline at end of file +kotlin.code.style=official diff --git a/src/main/kotlin/de/pheerai/rcdbquery/Sample.kt b/src/main/kotlin/de/pheerai/rcdbquery/Sample.kt index e3fb680..d790c0b 100644 --- a/src/main/kotlin/de/pheerai/rcdbquery/Sample.kt +++ b/src/main/kotlin/de/pheerai/rcdbquery/Sample.kt @@ -19,7 +19,7 @@ fun generateNameQueryUrl() = rcdbQuery { } sortBy { manufacturer() - inversion() + inversions() } } diff --git a/src/main/kotlin/de/pheerai/rcdbquery/dataMappings/Order.kt b/src/main/kotlin/de/pheerai/rcdbquery/dataMappings/Order.kt index f2cefdc..cb691fa 100644 --- a/src/main/kotlin/de/pheerai/rcdbquery/dataMappings/Order.kt +++ b/src/main/kotlin/de/pheerai/rcdbquery/dataMappings/Order.kt @@ -10,13 +10,7 @@ enum class Order( ) : RcdbParamOption { IMAGES("Images", "Amount of Images", 0), NAME("Name", "Name of the Coaster", 1), - - @Deprecated( - "The purpose of this parameter is yet unclear. You might want to use NAME instead", - level = DeprecationLevel.WARNING, - replaceWith = ReplaceWith("Order.NAME") - ) - NAME_2("Name", "Name of the Coaster. Difference to NAME not clear", 2), + ORIGINAL_NAME("Original Name", "Original name of the Coaster, in local charset", 2), LOCATION("Location", 3), PARK("Park", 4), OPENED("Opened", "Opening Date", 8), diff --git a/src/main/kotlin/de/pheerai/rcdbquery/dataMappings/RcdbParamOptionBuilder.kt b/src/main/kotlin/de/pheerai/rcdbquery/dataMappings/RcdbParamOptionBuilder.kt index ddd5c24..4018a0f 100644 --- a/src/main/kotlin/de/pheerai/rcdbquery/dataMappings/RcdbParamOptionBuilder.kt +++ b/src/main/kotlin/de/pheerai/rcdbquery/dataMappings/RcdbParamOptionBuilder.kt @@ -9,6 +9,11 @@ sealed class RcdbParamOptionBuilder> { return this } + protected open fun addAll(items: Array): RcdbParamOptionBuilder { + paramList.addAll(items) + return this + } + fun build() = paramList.toList() } @@ -32,7 +37,35 @@ class OrderBuilder : RcdbParamOptionBuilder() { return this } + override fun addAll(items: Array): OrderBuilder { + super.addAll(items) + return this + } + fun of(order: Order) = this.add(order) fun manufacturer() = this.add(Order.MANUFACTURER) - fun inversion() = this.add(Order.INVERSIONS) + fun inversions() = this.add(Order.INVERSIONS) + fun name() = this.add(Order.NAME) + fun location() = this.add(Order.LOCATION) + fun park() = this.add(Order.PARK) + fun opened() = this.add(Order.OPENED) + fun closed() = this.add(Order.CLOSED) + fun entered() = this.add(Order.ENTERED) + fun type() = this.add(Order.TYPE) + fun design() = this.add(Order.DESIGN) + fun classification() = this.add(Order.CLASSIFICATION) + fun layout() = this.add(Order.LAYOUT) + fun model() = this.add(Order.MODEL) + fun modelLine() = this.add(Order.MODEL_LINE) + fun speed() = this.add(Order.SPEED) + fun height() = this.add(Order.HEIGHT) + fun drop() = this.add(Order.DROP) + fun length() = this.add(Order.LENGTH) + fun angle() = this.add(Order.ANGLE) + fun serialNo() = this.add(Order.SERIAL_NO) + fun scale() = this.add(Order.SCALE) + fun rideTime() = this.add(Order.RIDE_TIME) + fun state() = this.add(Order.STATE) + fun closing() = this.add(Order.CLOSING) + fun all() = this.addAll(Order.values()) } diff --git a/src/main/kotlin/de/pheerai/rcdbquery/dataMappings/StartsWith.kt b/src/main/kotlin/de/pheerai/rcdbquery/dataMappings/StartsWith.kt new file mode 100644 index 0000000..c0b42a1 --- /dev/null +++ b/src/main/kotlin/de/pheerai/rcdbquery/dataMappings/StartsWith.kt @@ -0,0 +1,27 @@ +@file:Suppress("unused") + +package de.pheerai.rcdbquery.dataMappings + +import de.pheerai.rcdbquery.dsl.RcdbQueryParamsBuilder + +class StartsWith(override val paramValue: String): RcdbParamOption { + 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() + ) + } +} diff --git a/src/test/kotlin/de/pheerai/rcdbquery/dsl/RcdbQueryDslTest.kt b/src/test/kotlin/de/pheerai/rcdbquery/dsl/RcdbQueryDslTest.kt index 7ea5791..de81bea 100644 --- a/src/test/kotlin/de/pheerai/rcdbquery/dsl/RcdbQueryDslTest.kt +++ b/src/test/kotlin/de/pheerai/rcdbquery/dsl/RcdbQueryDslTest.kt @@ -18,7 +18,7 @@ class RcdbQueryDslTest { of(Vendor.MAURER) } sortBy { - inversion() + inversions() manufacturer() } }