Add new types:

- Category
 - Classification
 - Design
 - Layout
 - Order
 - Page
 - Status
 - Thrill
This commit is contained in:
Oliver Rümpelein 2020-05-07 15:01:29 +02:00
parent eb26cdfc97
commit 034c00ca5b
40 changed files with 477 additions and 54 deletions

View file

@ -0,0 +1,73 @@
package de.pheerai.rcdbquery.dataMappings.category
import de.pheerai.rcdbquery.dataMappings.internal.RcdbParamOption
import de.pheerai.rcdbquery.dataMappings.internal.StringGeneratable
enum class Category(
override val prettyName: String,
override val fullName: String,
override val paramValue: Long
) : RcdbParamOption<Long> {
FOURTH_DIMENSION("4th Dimension", 24),
BRAKEMAN("Brakeman", 290),
BUILT_INHOUSE("Built In-House", 28),
DARK_RIDE("Dark Ride", 74),
DUAL_STATION("Dual Station", 147),
ENCLOSED("Enclosed", 114),
FLOORLESS("Floorless", 111),
HYBRID("Hybrid", 219),
INDOOR("Indoor", 113),
MIRROR("Mirror", 27),
MOEBIUS("Möbius", 108),
ONBOARD_SOUND("Onboard Sound", 309),
PENDULUM("Pendulum", 82),
QUASI_MOEBIUS("Quasi Möbius", 37),
ROCKING_CARS("Rocking Cars", 34),
SCENIC_RAILWAY("Scenic Railway", 25),
SHUTTLE("Shuttle", 115),
SIDE_FRICTION("Side Friction", 106),
SINGLE_RAIL("Single Rail", 41),
SLIDING_STATION("Sliding Station", 26),
SPINNING_CARS("Spinning Cars", 105),
STACKED_STORAGE("Stacked Storage", 88),
TURNTABLE_STATION("Turntable Station", 42),
TWIN("Twin", 104),
VIRTUAL_REALITY("Virtual Reality", 32),
WATER_COASTER("Water Coaster", 103)
;
constructor(name: String, paramValue: Long) : this(name, name, paramValue)
companion object : StringGeneratable<Category> {
override val paramKey = "ca"
override fun of(input: String): Category? = when (input) {
"4th Dimension" -> FOURTH_DIMENSION
"Brakeman" -> BRAKEMAN
"Built In-House" -> BUILT_INHOUSE
"Dark Ride" -> DARK_RIDE
"Dual Station" -> DUAL_STATION
"Enclosed" -> ENCLOSED
"Floorless" -> FLOORLESS
"Hybrid" -> HYBRID
"Indoor" -> INDOOR
"Mirror" -> MIRROR
"Möbius" -> MOEBIUS
"Onboard Sound" -> ONBOARD_SOUND
"Pendulum" -> PENDULUM
"Quasi Möbius" -> QUASI_MOEBIUS
"Rocking Cars" -> ROCKING_CARS
"Scenic Railway" -> SCENIC_RAILWAY
"Shuttle" -> SHUTTLE
"Side Friction" -> SIDE_FRICTION
"Single Rail" -> SINGLE_RAIL
"Sliding Station" -> SLIDING_STATION
"Spinning Cars" -> SPINNING_CARS
"Stacked Storage" -> STACKED_STORAGE
"Turntable Station" -> TURNTABLE_STATION
"Twin" -> TWIN
"Virtual Reality" -> VIRTUAL_REALITY
"Water Coaster" -> WATER_COASTER
else -> null
}
}
}

View file

@ -0,0 +1,37 @@
package de.pheerai.rcdbquery.dataMappings.category
import de.pheerai.rcdbquery.dataMappings.internal.MultiParamBuilder
class CategoryBuilder: MultiParamBuilder<Long, Category>() {
override fun add(param: Category): CategoryBuilder {
super.add(param)
return this
}
fun fourthDimension() = this.add(Category.FOURTH_DIMENSION)
fun brakeman() = this.add(Category.BRAKEMAN)
fun builtInhouse() = this.add(Category.BUILT_INHOUSE)
fun darkride() = this.add(Category.DARK_RIDE)
fun dualStation() = this.add(Category.DUAL_STATION)
fun enclosed() = this.add(Category.ENCLOSED)
fun floorless() = this.add(Category.FLOORLESS)
fun hybrid() = this.add(Category.HYBRID)
fun indoor() = this.add(Category.INDOOR)
fun mirror() = this.add(Category.MIRROR)
fun moebius() = this.add(Category.MOEBIUS)
fun onboardSound() = this.add(Category.ONBOARD_SOUND)
fun pendulum() = this.add(Category.PENDULUM)
fun quasiMoebius() = this.add(Category.QUASI_MOEBIUS)
fun rockingCars() = this.add(Category.ROCKING_CARS)
fun scenicRailway() = this.add(Category.SCENIC_RAILWAY)
fun shuttle() = this.add(Category.SHUTTLE)
fun sideFriction() = this.add(Category.SIDE_FRICTION)
fun singleRail() = this.add(Category.SINGLE_RAIL)
fun slidingStation() = this.add(Category.SLIDING_STATION)
fun spinningCars() = this.add(Category.SPINNING_CARS)
fun stackedStorage() = this.add(Category.STACKED_STORAGE)
fun turntableStation() = this.add(Category.TURNTABLE_STATION)
fun twin() = this.add(Category.TWIN)
fun virtualReality() = this.add(Category.VIRTUAL_REALITY)
fun waterCoaster() = this.add(Category.WATER_COASTER)
}

View file

@ -0,0 +1,10 @@
package de.pheerai.rcdbquery.dataMappings.category
import de.pheerai.rcdbquery.dsl.ParamsCollector
fun ParamsCollector.category(body: CategoryBuilder.() -> CategoryBuilder): ParamsCollector {
val builder = CategoryBuilder()
builder.body()
this[Category.paramKey] = builder.build()
return this
}

View file

@ -1,20 +1,22 @@
package de.pheerai.rcdbquery.dataMappings.classification package de.pheerai.rcdbquery.dataMappings.classification
import de.pheerai.rcdbquery.dataMappings.internal.RcdbParamOption import de.pheerai.rcdbquery.dataMappings.internal.RcdbParamOption
import de.pheerai.rcdbquery.dataMappings.internal.StringGeneratable
enum class Classification( enum class Classification(
override val prettyName: String, override val prettyName: String,
override val fullName: String, override val fullName: String,
override val paramValue: Int override val paramValue: Long
) : RcdbParamOption<Int> { ) : RcdbParamOption<Long> {
ROLLER_COASTER("Roller Coaster", 277), ROLLER_COASTER("Roller Coaster", 277),
POWERED_COASTER("Powered Coaster", 278), POWERED_COASTER("Powered Coaster", 278),
MOUNTAIN_COASTER("Mountain Coaster", 279) MOUNTAIN_COASTER("Mountain Coaster", 279),
; ;
constructor(name: String, paramValue: Int) : this(name, name, paramValue) constructor(name: String, paramValue: Long) : this(name, name, paramValue)
companion object { companion object: StringGeneratable<Classification> {
const val staticParamName = "cs" override fun of(input: String) = values().find { it.fullName == input }
override val paramKey = "cs"
} }
} }

View file

@ -2,7 +2,7 @@ package de.pheerai.rcdbquery.dataMappings.classification
import de.pheerai.rcdbquery.dataMappings.internal.MultiParamBuilder import de.pheerai.rcdbquery.dataMappings.internal.MultiParamBuilder
class ClassificationBuilder : MultiParamBuilder<Int, Classification>() { class ClassificationBuilder : MultiParamBuilder<Long, Classification>() {
override fun add(param: Classification): ClassificationBuilder { override fun add(param: Classification): ClassificationBuilder {
super.add(param) super.add(param)
return this return this

View file

@ -5,6 +5,6 @@ import de.pheerai.rcdbquery.dsl.ParamsCollector
fun ParamsCollector.classification(body: ClassificationBuilder.() -> ClassificationBuilder): ParamsCollector { fun ParamsCollector.classification(body: ClassificationBuilder.() -> ClassificationBuilder): ParamsCollector {
val builder = ClassificationBuilder() val builder = ClassificationBuilder()
builder.body() builder.body()
this[Classification.staticParamName] = builder.build() this[Classification.paramKey] = builder.build()
return this return this
} }

View file

@ -0,0 +1,37 @@
package de.pheerai.rcdbquery.dataMappings.design
import de.pheerai.rcdbquery.dataMappings.internal.RcdbParamOption
import de.pheerai.rcdbquery.dataMappings.internal.StringGeneratable
enum class Design(
override val prettyName: String,
override val fullName: String,
override val paramValue: Long
) : RcdbParamOption<Long> {
SIT_DOWN("Sit Down", 6),
INVERTED("Inverted", 5),
SUSPENDED("Suspended", 8),
WING("Wing", 67),
FLYING("Flying", 4),
STAND_UP("Stand Up", 7),
BOBSLED("Bobsled", 3),
PIPELINE("Pipeline", 73)
;
constructor(name: String, paramValue: Long) : this(name, name, paramValue)
companion object : StringGeneratable<Design> {
override val paramKey = "de"
override fun of(input: String): Design? = when (input) {
"Sit Down" -> SIT_DOWN
"Inverted" -> INVERTED
"Suspended" -> SUSPENDED
"Wing" -> WING
"Flying" -> FLYING
"Stand Up" -> STAND_UP
"Bobsled" -> BOBSLED
"Pipeline" -> PIPELINE
else -> null
}
}
}

View file

@ -0,0 +1,19 @@
package de.pheerai.rcdbquery.dataMappings.design
import de.pheerai.rcdbquery.dataMappings.internal.MultiParamBuilder
class DesignBuilder : MultiParamBuilder<Long, Design>() {
override fun add(param: Design): DesignBuilder {
super.add(param)
return this
}
fun sitDown() = Design.SIT_DOWN
fun inverted() = Design.INVERTED
fun suspended() = Design.SUSPENDED
fun wing() = Design.WING
fun flying() = Design.FLYING
fun standUp() = Design.STAND_UP
fun bobsled() = Design.BOBSLED
fun pipeline() = Design.PIPELINE
}

View file

@ -0,0 +1,10 @@
package de.pheerai.rcdbquery.dataMappings.design
import de.pheerai.rcdbquery.dsl.ParamsCollector
fun ParamsCollector.design(body: DesignBuilder.() -> DesignBuilder): ParamsCollector {
val builder = DesignBuilder()
builder.body()
this[Design.paramKey] = builder.build()
return this
}

View file

@ -0,0 +1,5 @@
package de.pheerai.rcdbquery.dataMappings.internal
interface ParamKey {
val paramKey: String
}

View file

@ -0,0 +1,7 @@
package de.pheerai.rcdbquery.dataMappings.internal
interface RcdbItem {
val url: String
get() ="https://www.rcdb.com/${id}.htm"
val id: Long
}

View file

@ -0,0 +1,5 @@
package de.pheerai.rcdbquery.dataMappings.internal
interface StringGeneratable<T>: ParamKey {
fun of(input: String): T?
}

View file

@ -0,0 +1,45 @@
package de.pheerai.rcdbquery.dataMappings.layout
import de.pheerai.rcdbquery.dataMappings.internal.RcdbParamOption
import de.pheerai.rcdbquery.dataMappings.internal.StringGeneratable
enum class Layout(
override val prettyName: String,
override val fullName: String,
override val paramValue: Long
) : RcdbParamOption<Long> {
BIG_APPLE("Big Apple / Wacky Worm", 282),
CIRCLE_DIP("Circle Dip", 36),
CIRCULAR_GRAVIY_RAILWAY("Circular Gravity Railway", 269),
CYCLONE("Cyclone", 96),
DOUBLE_FIGURE_EIGHT("Double Figure Eight", 123),
DOUBLE_OUT_AND_BACK("Double Out and Back", 121),
FIGURE_EIGHT("Figure Eight", 102),
JUNGLE_MOUSE("Jungle Mouse", 305),
L_SHAPED_OUT_AND_BACK("L-Shaped Out and Back", 254),
MITE_MOUSE("Mite Mouse", 206),
OUT_AND_BACK("Out and Back", 99),
OVAL("Oval", 124),
SHUTTLE_LOOP("Shuttle Loop", 97),
SINGLE_HELIX_CENTER("Single Helix (center)", 142),
SINGLE_HELIX_LEFT("Single Helix (left)", 141),
SINGLE_HELIX_REAR("Single Helix (rear)", 83),
SINGLE_HELIX_RIGHT("Single Helix (right)", 139),
TERRAIN("Terrain", 125),
TRIANGLE("Triangle", 90),
TRIPLE_OUT_AND_BACK("Triple Out and Back", 301),
TWIN_HELIX("Twin Helix", 140),
TWISTER("Twister", 122),
U_SHUTTLE("U Shuttle", 81),
WILD_MOUSE("Wild Mouse", 95),
ZYKLON("Zyklon / Galaxy", 294)
;
constructor(name: String, paramValue: Long) : this(name, name, paramValue)
companion object : StringGeneratable<Layout> {
override val paramKey = "lo"
override fun of(input: String): Layout? = values().find { input == it.fullName }
}
}

View file

@ -0,0 +1,39 @@
package de.pheerai.rcdbquery.dataMappings.layout
import de.pheerai.rcdbquery.dataMappings.internal.MultiParamBuilder
class LayoutBuilder : MultiParamBuilder<Long, Layout>() {
override fun add(param: Layout): LayoutBuilder {
super.add(param)
return this
}
fun bigApple() = this.add(Layout.BIG_APPLE)
fun wackyWorm() = this.add(Layout.BIG_APPLE)
fun circleDip() = this.add(Layout.CIRCLE_DIP)
fun circularGravityRailway() = this.add(Layout.CIRCULAR_GRAVIY_RAILWAY)
fun cyclone() = this.add(Layout.CYCLONE)
fun doubleFigureEight() = this.add(Layout.DOUBLE_FIGURE_EIGHT)
fun doubleOutAndBack() = this.add(Layout.DOUBLE_OUT_AND_BACK)
fun figureEight() = this.add(Layout.FIGURE_EIGHT)
fun jungleMouse() = this.add(Layout.JUNGLE_MOUSE)
fun lShapedOutAndBack() = this.add(Layout.L_SHAPED_OUT_AND_BACK)
fun miteMouse() = this.add(Layout.MITE_MOUSE)
fun outAndBack() = this.add(Layout.OUT_AND_BACK)
fun oval() = this.add(Layout.OVAL)
fun shuttleLoop() = this.add(Layout.SHUTTLE_LOOP)
fun singleHelixCenter() = this.add(Layout.SINGLE_HELIX_CENTER)
fun singleHelixLeft() = this.add(Layout.SINGLE_HELIX_LEFT)
fun singleHelixRear() = this.add(Layout.SINGLE_HELIX_REAR)
fun singleHelixRight() = this.add(Layout.SINGLE_HELIX_RIGHT)
fun terrain() = this.add(Layout.TERRAIN)
fun triangle() = this.add(Layout.TRIANGLE)
fun tripleOutAndBack() = this.add(Layout.TRIPLE_OUT_AND_BACK)
fun twinHelix() = this.add(Layout.TWIN_HELIX)
fun twister() = this.add(Layout.TWISTER)
fun uShuttle() = this.add(Layout.U_SHUTTLE)
fun wildMouse() = this.add(Layout.WILD_MOUSE)
fun zyklon() = this.add(Layout.ZYKLON)
fun galaxy() = this.add(Layout.ZYKLON)
}

View file

@ -0,0 +1,10 @@
package de.pheerai.rcdbquery.dataMappings.layout
import de.pheerai.rcdbquery.dsl.ParamsCollector
fun ParamsCollector.layout(body: LayoutBuilder.() -> LayoutBuilder): ParamsCollector {
val builder = LayoutBuilder()
builder.body()
this[Layout.paramKey] = builder.build()
return this
}

View file

@ -1,15 +1,17 @@
package de.pheerai.rcdbquery.dataMappings.order package de.pheerai.rcdbquery.dataMappings.order
import de.pheerai.rcdbquery.dataMappings.internal.ParamKey
import de.pheerai.rcdbquery.dataMappings.internal.RcdbParamOption import de.pheerai.rcdbquery.dataMappings.internal.RcdbParamOption
import de.pheerai.rcdbquery.dataMappings.internal.RelevantForAll import de.pheerai.rcdbquery.dataMappings.internal.RelevantForAll
import de.pheerai.rcdbquery.dataMappings.internal.StringGeneratable
@Suppress("unused") @Suppress("unused")
enum class Order( enum class Order(
override val prettyName: String, override val prettyName: String,
override val fullName: String, override val fullName: String,
override val paramValue: Int, override val paramValue: Long,
override val relevantForAll: Boolean = true override val relevantForAll: Boolean = true
) : RcdbParamOption<Int>, ) : RcdbParamOption<Long>,
RelevantForAll { RelevantForAll {
IMAGES("Images", "Amount of Images", 0), IMAGES("Images", "Amount of Images", 0),
NAME("Name", "Name of the Coaster", 1), NAME("Name", "Name of the Coaster", 1),
@ -46,9 +48,9 @@ enum class Order(
CLOSING("Closing", "(Future) closign date for temporary installations", 31) CLOSING("Closing", "(Future) closign date for temporary installations", 31)
; ;
constructor(name: String, paramId: Int) : this(name, name, paramId) constructor(name: String, paramId: Long) : this(name, name, paramId)
companion object { companion object: ParamKey {
const val staticParamName = "order" override val paramKey = "order"
} }
} }

View file

@ -2,7 +2,7 @@ package de.pheerai.rcdbquery.dataMappings.order
import de.pheerai.rcdbquery.dataMappings.internal.MultiParamBuilder import de.pheerai.rcdbquery.dataMappings.internal.MultiParamBuilder
class OrderBuilder : MultiParamBuilder<Int, Order>() { class OrderBuilder : MultiParamBuilder<Long, Order>() {
override fun add(param: Order): OrderBuilder { override fun add(param: Order): OrderBuilder {
super.add(param) super.add(param)
return this return this

View file

@ -5,6 +5,6 @@ import de.pheerai.rcdbquery.dsl.ParamsCollector
fun ParamsCollector.sortBy(body: OrderBuilder.() -> OrderBuilder): ParamsCollector { fun ParamsCollector.sortBy(body: OrderBuilder.() -> OrderBuilder): ParamsCollector {
val builder = OrderBuilder() val builder = OrderBuilder()
builder.body() builder.body()
this[Order.staticParamName] = builder.build() this[Order.paramKey] = builder.build()
return this return this
} }

View file

@ -1,13 +1,14 @@
package de.pheerai.rcdbquery.dataMappings.page package de.pheerai.rcdbquery.dataMappings.page
import de.pheerai.rcdbquery.dataMappings.internal.ParamKey
import de.pheerai.rcdbquery.dataMappings.internal.RcdbParamOption import de.pheerai.rcdbquery.dataMappings.internal.RcdbParamOption
class Page(override val paramValue: Int) : class Page(override val paramValue: Long) :
RcdbParamOption<Int> { RcdbParamOption<Long> {
override val fullName = "The page to show" override val fullName = "The page to show"
override val prettyName = "Page" override val prettyName = "Page"
companion object { companion object: ParamKey {
const val staticParamName = "page" override val paramKey = "page"
} }
} }

View file

@ -2,7 +2,7 @@ package de.pheerai.rcdbquery.dataMappings.page
import de.pheerai.rcdbquery.dsl.ParamsCollector import de.pheerai.rcdbquery.dsl.ParamsCollector
fun ParamsCollector.page(page: Int) = also { fun ParamsCollector.page(page: Long) = also {
this[Page.staticParamName] = this[Page.paramKey] =
Page(page) Page(page)
} }

View file

@ -1,5 +1,6 @@
package de.pheerai.rcdbquery.dataMappings.searchTerm package de.pheerai.rcdbquery.dataMappings.searchTerm
import de.pheerai.rcdbquery.dataMappings.internal.ParamKey
import de.pheerai.rcdbquery.dataMappings.internal.RcdbParamOption import de.pheerai.rcdbquery.dataMappings.internal.RcdbParamOption
class SearchTerm(override val paramValue: String) : class SearchTerm(override val paramValue: String) :
@ -7,7 +8,7 @@ class SearchTerm(override val paramValue: String) :
override val prettyName = "Search Term" override val prettyName = "Search Term"
override val fullName = "Search for elements whose name contain this term" override val fullName = "Search for elements whose name contain this term"
companion object { companion object: ParamKey {
const val staticParamName = "nc" override val paramKey = "nc"
} }
} }

View file

@ -3,7 +3,7 @@ package de.pheerai.rcdbquery.dataMappings.searchTerm
import de.pheerai.rcdbquery.dsl.ParamsCollector import de.pheerai.rcdbquery.dsl.ParamsCollector
fun ParamsCollector.searchTerm(term: String) = also { fun ParamsCollector.searchTerm(term: String) = also {
it[SearchTerm.staticParamName] = listOf( it[SearchTerm.paramKey] = listOf(
SearchTerm(term) SearchTerm(term)
) )
} }

View file

@ -1,20 +1,21 @@
package de.pheerai.rcdbquery.dataMappings.searchType package de.pheerai.rcdbquery.dataMappings.searchType
import de.pheerai.rcdbquery.dataMappings.internal.ParamKey
import de.pheerai.rcdbquery.dataMappings.internal.RcdbParamOption import de.pheerai.rcdbquery.dataMappings.internal.RcdbParamOption
@Suppress("unused") @Suppress("unused")
enum class SearchType( enum class SearchType(
override val prettyName: String, override val prettyName: String,
override val fullName: String, override val fullName: String,
override val paramValue: Int override val paramValue: Long
) : RcdbParamOption<Int> { ) : RcdbParamOption<Long> {
COASTER("Coaster", "Search for Roller Coaster", 2), COASTER("Coaster", "Search for Roller Coaster", 2),
AMUSEMENT_PARK("Amusement Parks", "Searh for an amusement park", 3), AMUSEMENT_PARK("Amusement Parks", "Searh for an amusement park", 3),
COMPANY("Company", "Search for company (manufacturer, engineering,...)", 12), COMPANY("Company", "Search for company (manufacturer, engineering,...)", 12),
PERSON("Person", "Search for a person (designer, engineer,...)", 13) PERSON("Person", "Search for a person (designer, engineer,...)", 13)
; ;
companion object { companion object: ParamKey {
const val staticParamName = "ot" override val paramKey = "ot"
} }
} }

View file

@ -3,5 +3,5 @@ package de.pheerai.rcdbquery.dataMappings.searchType
import de.pheerai.rcdbquery.dsl.ParamsCollector import de.pheerai.rcdbquery.dsl.ParamsCollector
fun ParamsCollector.searchType(searchType: SearchType) = also { fun ParamsCollector.searchType(searchType: SearchType) = also {
it[SearchType.staticParamName] = searchType it[SearchType.paramKey] = searchType
} }

View file

@ -2,6 +2,7 @@
package de.pheerai.rcdbquery.dataMappings.startsWith package de.pheerai.rcdbquery.dataMappings.startsWith
import de.pheerai.rcdbquery.dataMappings.internal.ParamKey
import de.pheerai.rcdbquery.dataMappings.internal.RcdbParamOption import de.pheerai.rcdbquery.dataMappings.internal.RcdbParamOption
class StartsWith(override val paramValue: String) : class StartsWith(override val paramValue: String) :
@ -9,8 +10,8 @@ class StartsWith(override val paramValue: String) :
override val prettyName = "Starts with" override val prettyName = "Starts with"
override val fullName = "Name starting with term" override val fullName = "Name starting with term"
companion object { companion object: ParamKey {
const val staticParamName = "nl" override val paramKey = "nl"
} }
} }

View file

@ -3,6 +3,6 @@ package de.pheerai.rcdbquery.dataMappings.startsWith
import de.pheerai.rcdbquery.dsl.ParamsCollector import de.pheerai.rcdbquery.dsl.ParamsCollector
fun ParamsCollector.startsWith(term: String) = also { fun ParamsCollector.startsWith(term: String) = also {
this[StartsWith.staticParamName] = this[StartsWith.paramKey] =
StartsWith(term) StartsWith(term)
} }

View file

@ -1,25 +1,27 @@
package de.pheerai.rcdbquery.dataMappings.status package de.pheerai.rcdbquery.dataMappings.status
import de.pheerai.rcdbquery.dataMappings.internal.RcdbParamOption import de.pheerai.rcdbquery.dataMappings.internal.RcdbParamOption
import de.pheerai.rcdbquery.dataMappings.internal.StringGeneratable
@Suppress("unused") @Suppress("unused")
enum class Status( enum class Status(
override val prettyName: String, override val prettyName: String,
override val fullName: String, override val fullName: String,
override val paramValue: Int override val paramValue: Long
) : RcdbParamOption<Int> { ) : RcdbParamOption<Long> {
SBNO("SBNO", "Standing, but not operating", 311), SBNO("SBNO", 311),
OPERATING("Operating", "In operation", 93), OPERATING("Operating", 93),
UNDER_CONSTRUCTION("Under Construction", 310), UNDER_CONSTRUCTION("Under Construction", 310),
STORED("Stored", "In storage", 312) STORED("Stored", "In Storage", 312),
RELOCATED("Relocated", -1),
; ;
constructor(name: String, paramId: Int) : this(name, name, paramId) constructor(name: String, paramId: Long) : this(name, name, paramId)
companion object { companion object: StringGeneratable<Status> {
const val staticParamName = "st" override val paramKey = "st"
fun of(input: String) = when (input) { override fun of(input: String) = when (input) {
"SBNO" -> SBNO "SBNO" -> SBNO
"Operating" -> OPERATING "Operating" -> OPERATING
"Under Construction" -> UNDER_CONSTRUCTION "Under Construction" -> UNDER_CONSTRUCTION
@ -28,4 +30,3 @@ enum class Status(
} }
} }
} }

View file

@ -2,7 +2,7 @@ package de.pheerai.rcdbquery.dataMappings.status
import de.pheerai.rcdbquery.dataMappings.internal.MultiParamBuilder import de.pheerai.rcdbquery.dataMappings.internal.MultiParamBuilder
class StatusBuilder : MultiParamBuilder<Int, Status>() { class StatusBuilder : MultiParamBuilder<Long, Status>() {
override fun add(param: Status): StatusBuilder { override fun add(param: Status): StatusBuilder {
super.add(param) super.add(param)
return this return this

View file

@ -5,6 +5,6 @@ import de.pheerai.rcdbquery.dsl.ParamsCollector
fun ParamsCollector.status(body: StatusBuilder.() -> StatusBuilder): ParamsCollector { fun ParamsCollector.status(body: StatusBuilder.() -> StatusBuilder): ParamsCollector {
val builder = StatusBuilder() val builder = StatusBuilder()
builder.body() builder.body()
this[Status.staticParamName] = builder.build() this[Status.paramKey] = builder.build()
return this return this
} }

View file

@ -0,0 +1,30 @@
package de.pheerai.rcdbquery.dataMappings.thrill
import de.pheerai.rcdbquery.dataMappings.internal.RcdbParamOption
import de.pheerai.rcdbquery.dataMappings.internal.StringGeneratable
enum class Thrill(
override val prettyName: String,
override val fullName: String,
override val paramValue: Long
) : RcdbParamOption<Long> {
KIDDIE("Kiddie", 21),
FAMILY("Family", 22),
THRILL("Thrill", 23),
EXTREME("Extreme", 20)
;
constructor(name: String, paramValue: Long) : this(name, name, paramValue)
companion object : StringGeneratable<Thrill> {
override val paramKey = "sc"
override fun of(input: String): Thrill? = when (input) {
"Kiddie" -> KIDDIE
"Family" -> FAMILY
"Thrill" -> THRILL
"Extreme" -> EXTREME
else -> null
}
}
}

View file

@ -0,0 +1,15 @@
package de.pheerai.rcdbquery.dataMappings.thrill
import de.pheerai.rcdbquery.dataMappings.internal.MultiParamBuilder
class ThrillBuilder : MultiParamBuilder<Long, Thrill>() {
override fun add(param: Thrill): ThrillBuilder {
super.add(param)
return this
}
fun kiddie() = this.add(Thrill.KIDDIE)
fun family() = this.add(Thrill.FAMILY)
fun thrill() = this.add(Thrill.THRILL)
fun extreme() = this.add(Thrill.EXTREME)
}

View file

@ -0,0 +1,10 @@
package de.pheerai.rcdbquery.dataMappings.thrill
import de.pheerai.rcdbquery.dsl.ParamsCollector
fun ParamsCollector.type(body: ThrillBuilder.() -> ThrillBuilder): ParamsCollector {
val builder = ThrillBuilder()
builder.body()
this[Thrill.paramKey] = builder.build()
return this
}

View file

@ -0,0 +1,26 @@
package de.pheerai.rcdbquery.dataMappings.type
import de.pheerai.rcdbquery.dataMappings.internal.RcdbParamOption
import de.pheerai.rcdbquery.dataMappings.internal.StringGeneratable
enum class Type(
override val prettyName: String,
override val fullName: String,
override val paramValue: Long
): RcdbParamOption<Long> {
STEEL("Steel", 1),
WOOD("Wood", 2),
;
constructor(name: String, paramValue: Long): this(name, name, paramValue)
companion object: StringGeneratable<Type> {
override val paramKey = "ty"
override fun of(input: String) = when(input) {
"Steel" -> STEEL
"Wood" -> WOOD
else -> null
}
}
}

View file

@ -0,0 +1,13 @@
package de.pheerai.rcdbquery.dataMappings.type
import de.pheerai.rcdbquery.dataMappings.internal.MultiParamBuilder
class TypeBuilder : MultiParamBuilder<Long, Type>() {
override fun add(param: Type): TypeBuilder {
super.add(param)
return this
}
fun steel() = this.add(Type.STEEL)
fun wood() = this.add(Type.WOOD)
}

View file

@ -0,0 +1,12 @@
package de.pheerai.rcdbquery.dataMappings.type
import de.pheerai.rcdbquery.dataMappings.thrill.Thrill
import de.pheerai.rcdbquery.dataMappings.thrill.ThrillBuilder
import de.pheerai.rcdbquery.dsl.ParamsCollector
fun ParamsCollector.thrill(body: ThrillBuilder.() -> ThrillBuilder): ParamsCollector {
val builder = ThrillBuilder()
builder.body()
this[Thrill.paramKey] = builder.build()
return this
}

View file

@ -1,13 +1,15 @@
package de.pheerai.rcdbquery.dataMappings.vendor package de.pheerai.rcdbquery.dataMappings.vendor
import de.pheerai.rcdbquery.dataMappings.internal.RcdbItem
import de.pheerai.rcdbquery.dataMappings.internal.RcdbParamOption import de.pheerai.rcdbquery.dataMappings.internal.RcdbParamOption
import de.pheerai.rcdbquery.dataMappings.internal.StringGeneratable
@Suppress("unused") @Suppress("unused")
enum class Vendor( enum class Vendor(
override val prettyName: String, override val prettyName: String,
override val fullName: String, override val fullName: String,
override val paramValue: Int override val paramValue: Long
) : RcdbParamOption<Int> { ) : RcdbParamOption<Long>, RcdbItem {
YAQIAO_MACHINE("Yaqiao", "Yaqiao Machine", 6471), YAQIAO_MACHINE("Yaqiao", "Yaqiao Machine", 6471),
CREDIBLE("Credible", 6584), CREDIBLE("Credible", 6584),
ARROW("Arrow", "Arrow Dynamics", 6835), ARROW("Arrow", "Arrow Dynamics", 6835),
@ -239,15 +241,18 @@ enum class Vendor(
SBF_VISA("SBF Visa", "SBF Visa Group", 7028), SBF_VISA("SBF Visa", "SBF Visa Group", 7028),
ZAMPERLA("Zamperla", 6892), ZAMPERLA("Zamperla", 6892),
GCI("GCI", "Great Coasters International", 6860), GCI("GCI", "Great Coasters International", 6860),
RMC("RMC", "Rocky Mountain Construction", 10583) RMC("RMC", "Rocky Mountain Construction", 10583),
; ;
constructor(name: String, paramId: Int) : this(name, name, paramId) override val id: Long
get() = this.paramValue
companion object { constructor(name: String, paramId: Long) : this(name, name, paramId)
const val staticParamName = "mk"
companion object: StringGeneratable<Vendor> {
override val paramKey = "mk"
override fun of(input: String) = values().find { input == it.prettyName }
fun getByName(name: String) = values().firstOrNull { it.prettyName == name }
fun searchByName(name: String): List<Vendor> { fun searchByName(name: String): List<Vendor> {
val searchName = name.toLowerCase() val searchName = name.toLowerCase()
return values().filter { return values().filter {

View file

@ -2,7 +2,7 @@ package de.pheerai.rcdbquery.dataMappings.vendor
import de.pheerai.rcdbquery.dataMappings.internal.MultiParamBuilder import de.pheerai.rcdbquery.dataMappings.internal.MultiParamBuilder
class VendorBuilder : MultiParamBuilder<Int, Vendor>() { class VendorBuilder : MultiParamBuilder<Long, Vendor>() {
override fun add(param: Vendor): VendorBuilder { override fun add(param: Vendor): VendorBuilder {
super.add(param) super.add(param)
return this return this

View file

@ -2,9 +2,10 @@ package de.pheerai.rcdbquery.dataMappings.vendor
import de.pheerai.rcdbquery.dsl.ParamsCollector import de.pheerai.rcdbquery.dsl.ParamsCollector
// TODO: Try to generify. This is currently lacking some sort of "This interface requires a companion implementing that interface"
fun ParamsCollector.vendors(body: VendorBuilder.() -> VendorBuilder): ParamsCollector { fun ParamsCollector.vendors(body: VendorBuilder.() -> VendorBuilder): ParamsCollector {
val builder = VendorBuilder() val builder = VendorBuilder()
builder.body() builder.body()
this[Vendor.staticParamName] = builder.build() this[Vendor.paramKey] = builder.build()
return this return this
} }

View file

@ -51,7 +51,7 @@ class ParamsCollector {
.let { MultiParams(it) } .let { MultiParams(it) }
private fun buildSingle() = singleParams.apply { private fun buildSingle() = singleParams.apply {
putIfAbsent(SearchType.staticParamName, SearchType.COASTER) putIfAbsent(SearchType.paramKey, SearchType.COASTER)
} }
.mapValues { e -> e.value.paramValue.toString() } .mapValues { e -> e.value.paramValue.toString() }
.let { SingleParams(it) } .let { SingleParams(it) }

View file

@ -1,11 +1,16 @@
module rcdbquery.main { module rcdbquery.main {
exports de.pheerai.rcdbquery.dataMappings.category;
exports de.pheerai.rcdbquery.dataMappings.classification; exports de.pheerai.rcdbquery.dataMappings.classification;
exports de.pheerai.rcdbquery.dataMappings.design;
exports de.pheerai.rcdbquery.dataMappings.layout;
exports de.pheerai.rcdbquery.dataMappings.order; exports de.pheerai.rcdbquery.dataMappings.order;
exports de.pheerai.rcdbquery.dataMappings.page; exports de.pheerai.rcdbquery.dataMappings.page;
exports de.pheerai.rcdbquery.dataMappings.searchTerm; exports de.pheerai.rcdbquery.dataMappings.searchTerm;
exports de.pheerai.rcdbquery.dataMappings.searchType; exports de.pheerai.rcdbquery.dataMappings.searchType;
exports de.pheerai.rcdbquery.dataMappings.startsWith; exports de.pheerai.rcdbquery.dataMappings.startsWith;
exports de.pheerai.rcdbquery.dataMappings.status; exports de.pheerai.rcdbquery.dataMappings.status;
exports de.pheerai.rcdbquery.dataMappings.thrill;
exports de.pheerai.rcdbquery.dataMappings.type;
exports de.pheerai.rcdbquery.dataMappings.vendor; exports de.pheerai.rcdbquery.dataMappings.vendor;
exports de.pheerai.rcdbquery.dsl; exports de.pheerai.rcdbquery.dsl;