Oliver Rümpelein
d2dc84a17b
- You can now return "all" data available - The use of `Order.NAME_2` has been found and the item has been change to - `ORIGINAL_NAME` to reflect this - All `Order`-types now have their designated DSL method - It is now possible to search for items starting with a term - `inversion()` Order method has been renamed to `inversions()`
72 lines
2.3 KiB
Kotlin
72 lines
2.3 KiB
Kotlin
package de.pheerai.rcdbquery.dataMappings
|
|
|
|
// TODO: Find way to only have one generic parameter
|
|
sealed class RcdbParamOptionBuilder<out U : Any, T : RcdbParamOption<U>> {
|
|
private val paramList: MutableList<T> = mutableListOf()
|
|
|
|
open fun add(param: T): RcdbParamOptionBuilder<U, T> {
|
|
paramList.add(param)
|
|
return this
|
|
}
|
|
|
|
protected open fun addAll(items: Array<T>): RcdbParamOptionBuilder<U, T> {
|
|
paramList.addAll(items)
|
|
return this
|
|
}
|
|
|
|
fun build() = paramList.toList()
|
|
}
|
|
|
|
class VendorBuilder : RcdbParamOptionBuilder<Int, Vendor>() {
|
|
override fun add(param: Vendor): VendorBuilder {
|
|
super.add(param)
|
|
return this
|
|
}
|
|
|
|
fun of(vendor: Vendor) = this.add(vendor)
|
|
fun vekoma() = this.add(Vendor.VEKOMA)
|
|
fun intamin() = this.add(Vendor.INTAMIN)
|
|
fun mack() = this.add(Vendor.MACK)
|
|
fun bandm() = this.add(Vendor.B_AND_M)
|
|
fun gerstlauer() = this.add(Vendor.GERSTLAUER)
|
|
}
|
|
|
|
class OrderBuilder : RcdbParamOptionBuilder<Int, Order>() {
|
|
override fun add(param: Order): OrderBuilder {
|
|
super.add(param)
|
|
return this
|
|
}
|
|
|
|
override fun addAll(items: Array<Order>): OrderBuilder {
|
|
super.addAll(items)
|
|
return this
|
|
}
|
|
|
|
fun of(order: Order) = this.add(order)
|
|
fun manufacturer() = this.add(Order.MANUFACTURER)
|
|
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())
|
|
}
|