105 lines
3.4 KiB
Kotlin
105 lines
3.4 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
|
|
}
|
|
|
|
protected open fun addAll(items: Collection<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
|
|
}
|
|
|
|
override fun addAll(items: Collection<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.STATUS)
|
|
fun closing() = this.add(Order.CLOSING)
|
|
fun all() = this.addAll(Order.values().filter { it.relevantForAll })
|
|
}
|
|
|
|
class StatusBuilder : RcdbParamOptionBuilder<Int, Status>() {
|
|
override fun add(param: Status): StatusBuilder {
|
|
super.add(param)
|
|
return this
|
|
}
|
|
|
|
fun sbno() = this.add(Status.SBNO)
|
|
fun operating() = this.add(Status.OPERATING)
|
|
fun underConstruction() = this.add(Status.UNDER_CONSTRUCTION)
|
|
fun stored() = this.add(Status.STORED)
|
|
}
|
|
|
|
class ClassificationBuilder : RcdbParamOptionBuilder<Int, Classification>() {
|
|
override fun add(param: Classification): ClassificationBuilder {
|
|
super.add(param)
|
|
return this
|
|
}
|
|
|
|
fun rollerCoaster() = this.add(Classification.ROLLERCOASTER)
|
|
fun poweredCoaster() = this.add(Classification.POWERED_COASTER)
|
|
fun mountainCoaster() = this.add(Classification.MOUNTAIN_COASTER)
|
|
}
|