Adoptions to explicit API (WIP)
This commit is contained in:
parent
bdd8c1d7d9
commit
00f74792d5
48 changed files with 63 additions and 62 deletions
|
@ -10,12 +10,12 @@ import de.pheerai.rcdbquery.dataMappings.vendor.Vendor.*
|
|||
import de.pheerai.rcdbquery.dataMappings.vendor.vendors
|
||||
import de.pheerai.rcdbquery.dsl.rcdbQuery
|
||||
|
||||
fun main() {
|
||||
public fun main() {
|
||||
println(generateNameQueryUrl())
|
||||
println(generatePageQueryUrl())
|
||||
}
|
||||
|
||||
fun generateNameQueryUrl() = rcdbQuery {
|
||||
private fun generateNameQueryUrl() = rcdbQuery {
|
||||
searchType(SearchType.COASTER)
|
||||
searchTerm("Dragon")
|
||||
vendors {
|
||||
|
@ -29,7 +29,7 @@ fun generateNameQueryUrl() = rcdbQuery {
|
|||
}
|
||||
}
|
||||
|
||||
fun generatePageQueryUrl() = rcdbQuery {
|
||||
private fun generatePageQueryUrl() = rcdbQuery {
|
||||
page(3)
|
||||
searchType(SearchType.COASTER)
|
||||
vendors {
|
||||
|
|
|
@ -3,7 +3,7 @@ package de.pheerai.rcdbquery.dataMappings.category
|
|||
import de.pheerai.rcdbquery.dataMappings.internal.RcdbParamOption
|
||||
import de.pheerai.rcdbquery.dataMappings.internal.StringGeneratable
|
||||
|
||||
enum class Category(
|
||||
public enum class Category(
|
||||
override val prettyName: String,
|
||||
override val fullName: String,
|
||||
override val paramValue: Long
|
||||
|
@ -38,7 +38,7 @@ enum class Category(
|
|||
|
||||
constructor(name: String, paramValue: Long) : this(name, name, paramValue)
|
||||
|
||||
companion object : StringGeneratable<Category> {
|
||||
internal companion object : StringGeneratable<Category> {
|
||||
override val paramKey = "ca"
|
||||
override fun of(input: String): Category? = when (input) {
|
||||
"4th Dimension" -> FOURTH_DIMENSION
|
||||
|
|
|
@ -2,7 +2,7 @@ package de.pheerai.rcdbquery.dataMappings.category
|
|||
|
||||
import de.pheerai.rcdbquery.dataMappings.internal.MultiParamBuilder
|
||||
|
||||
class CategoryBuilder : MultiParamBuilder<Long, Category>() {
|
||||
internal class CategoryBuilder : MultiParamBuilder<Long, Category>() {
|
||||
override fun add(param: Category): CategoryBuilder {
|
||||
super.add(param)
|
||||
return this
|
||||
|
|
|
@ -2,7 +2,7 @@ package de.pheerai.rcdbquery.dataMappings.category
|
|||
|
||||
import de.pheerai.rcdbquery.dsl.params.ParamsCollector
|
||||
|
||||
fun ParamsCollector.category(body: CategoryBuilder.() -> CategoryBuilder): ParamsCollector {
|
||||
private fun ParamsCollector.category(body: CategoryBuilder.() -> CategoryBuilder): ParamsCollector {
|
||||
val builder = CategoryBuilder()
|
||||
builder.body()
|
||||
this[Category.paramKey] = builder.build()
|
||||
|
|
|
@ -3,7 +3,7 @@ package de.pheerai.rcdbquery.dataMappings.classification
|
|||
import de.pheerai.rcdbquery.dataMappings.internal.RcdbParamOption
|
||||
import de.pheerai.rcdbquery.dataMappings.internal.StringGeneratable
|
||||
|
||||
enum class Classification(
|
||||
internal enum class Classification(
|
||||
override val prettyName: String,
|
||||
override val fullName: String,
|
||||
override val paramValue: Long
|
||||
|
|
|
@ -2,7 +2,7 @@ package de.pheerai.rcdbquery.dataMappings.classification
|
|||
|
||||
import de.pheerai.rcdbquery.dataMappings.internal.MultiParamBuilder
|
||||
|
||||
class ClassificationBuilder : MultiParamBuilder<Long, Classification>() {
|
||||
internal class ClassificationBuilder : MultiParamBuilder<Long, Classification>() {
|
||||
override fun add(param: Classification): ClassificationBuilder {
|
||||
super.add(param)
|
||||
return this
|
||||
|
|
|
@ -2,7 +2,7 @@ package de.pheerai.rcdbquery.dataMappings.classification
|
|||
|
||||
import de.pheerai.rcdbquery.dsl.params.ParamsCollector
|
||||
|
||||
fun ParamsCollector.classification(body: ClassificationBuilder.() -> ClassificationBuilder): ParamsCollector {
|
||||
private fun ParamsCollector.classification(body: ClassificationBuilder.() -> ClassificationBuilder): ParamsCollector {
|
||||
val builder = ClassificationBuilder()
|
||||
builder.body()
|
||||
this[Classification.paramKey] = builder.build()
|
||||
|
|
|
@ -3,7 +3,7 @@ package de.pheerai.rcdbquery.dataMappings.design
|
|||
import de.pheerai.rcdbquery.dataMappings.internal.RcdbParamOption
|
||||
import de.pheerai.rcdbquery.dataMappings.internal.StringGeneratable
|
||||
|
||||
enum class Design(
|
||||
internal enum class Design(
|
||||
override val prettyName: String,
|
||||
override val fullName: String,
|
||||
override val paramValue: Long
|
||||
|
|
|
@ -2,7 +2,7 @@ package de.pheerai.rcdbquery.dataMappings.design
|
|||
|
||||
import de.pheerai.rcdbquery.dataMappings.internal.MultiParamBuilder
|
||||
|
||||
class DesignBuilder : MultiParamBuilder<Long, Design>() {
|
||||
internal class DesignBuilder : MultiParamBuilder<Long, Design>() {
|
||||
override fun add(param: Design): DesignBuilder {
|
||||
super.add(param)
|
||||
return this
|
||||
|
|
|
@ -2,7 +2,7 @@ package de.pheerai.rcdbquery.dataMappings.design
|
|||
|
||||
import de.pheerai.rcdbquery.dsl.params.ParamsCollector
|
||||
|
||||
fun ParamsCollector.design(body: DesignBuilder.() -> DesignBuilder): ParamsCollector {
|
||||
private fun ParamsCollector.design(body: DesignBuilder.() -> DesignBuilder): ParamsCollector {
|
||||
val builder = DesignBuilder()
|
||||
builder.body()
|
||||
this[Design.paramKey] = builder.build()
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package de.pheerai.rcdbquery.dataMappings.internal
|
||||
|
||||
abstract class MultiParamBuilder<out U : Any, T : RcdbParamOption<U>> {
|
||||
internal abstract class MultiParamBuilder<out U : Any, T : RcdbParamOption<U>> {
|
||||
private val paramList: MutableList<T> = mutableListOf()
|
||||
|
||||
open fun add(param: T): MultiParamBuilder<U, T> {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package de.pheerai.rcdbquery.dataMappings.internal
|
||||
|
||||
interface ParamKey {
|
||||
internal interface ParamKey {
|
||||
val paramKey: String
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package de.pheerai.rcdbquery.dataMappings.internal
|
||||
|
||||
interface RcdbItem {
|
||||
internal interface RcdbItem {
|
||||
val url: String
|
||||
get() ="https://www.rcdb.com/${id}.htm"
|
||||
val id: Long
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package de.pheerai.rcdbquery.dataMappings.internal
|
||||
|
||||
interface RcdbParamOption<out T> {
|
||||
internal interface RcdbParamOption<out T> {
|
||||
val prettyName: String
|
||||
val fullName: String
|
||||
val paramValue: T
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package de.pheerai.rcdbquery.dataMappings.internal
|
||||
|
||||
interface RelevantForAll {
|
||||
internal interface RelevantForAll {
|
||||
val relevantForAll: Boolean
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package de.pheerai.rcdbquery.dataMappings.internal
|
||||
|
||||
interface StringGeneratable<T>: ParamKey {
|
||||
internal interface StringGeneratable<T>: ParamKey {
|
||||
fun of(input: String): T?
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ package de.pheerai.rcdbquery.dataMappings.layout
|
|||
import de.pheerai.rcdbquery.dataMappings.internal.RcdbParamOption
|
||||
import de.pheerai.rcdbquery.dataMappings.internal.StringGeneratable
|
||||
|
||||
enum class Layout(
|
||||
internal enum class Layout(
|
||||
override val prettyName: String,
|
||||
override val fullName: String,
|
||||
override val paramValue: Long
|
||||
|
|
|
@ -2,7 +2,7 @@ package de.pheerai.rcdbquery.dataMappings.layout
|
|||
|
||||
import de.pheerai.rcdbquery.dataMappings.internal.MultiParamBuilder
|
||||
|
||||
class LayoutBuilder : MultiParamBuilder<Long, Layout>() {
|
||||
internal class LayoutBuilder : MultiParamBuilder<Long, Layout>() {
|
||||
override fun add(param: Layout): LayoutBuilder {
|
||||
super.add(param)
|
||||
return this
|
||||
|
|
|
@ -2,7 +2,7 @@ package de.pheerai.rcdbquery.dataMappings.layout
|
|||
|
||||
import de.pheerai.rcdbquery.dsl.params.ParamsCollector
|
||||
|
||||
fun ParamsCollector.layout(body: LayoutBuilder.() -> LayoutBuilder): ParamsCollector {
|
||||
private fun ParamsCollector.layout(body: LayoutBuilder.() -> LayoutBuilder): ParamsCollector {
|
||||
val builder = LayoutBuilder()
|
||||
with(Layout) {
|
||||
builder.body()
|
||||
|
|
|
@ -3,14 +3,13 @@ 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.RelevantForAll
|
||||
import de.pheerai.rcdbquery.dataMappings.internal.StringGeneratable
|
||||
|
||||
@Suppress("unused")
|
||||
enum class Order(
|
||||
internal enum class Order(
|
||||
override val prettyName: String,
|
||||
override val fullName: String,
|
||||
override val paramValue: Long,
|
||||
override val relevantForAll: Boolean = true
|
||||
override val relevantForAll: Boolean = true,
|
||||
) : RcdbParamOption<Long>,
|
||||
RelevantForAll {
|
||||
IMAGES("Images", "Amount of Images", 0),
|
||||
|
|
|
@ -2,7 +2,7 @@ package de.pheerai.rcdbquery.dataMappings.order
|
|||
|
||||
import de.pheerai.rcdbquery.dataMappings.internal.MultiParamBuilder
|
||||
|
||||
class OrderBuilder : MultiParamBuilder<Long, Order>() {
|
||||
internal class OrderBuilder : MultiParamBuilder<Long, Order>() {
|
||||
override fun add(param: Order): OrderBuilder {
|
||||
super.add(param)
|
||||
return this
|
||||
|
@ -18,6 +18,6 @@ class OrderBuilder : MultiParamBuilder<Long, Order>() {
|
|||
return this
|
||||
}
|
||||
|
||||
override fun Order.invoke() = add(this)
|
||||
override operator fun Order.invoke() = add(this)
|
||||
fun allRelevant() = this.addAll(Order.values().filter { it.relevantForAll })
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package de.pheerai.rcdbquery.dataMappings.order
|
|||
|
||||
import de.pheerai.rcdbquery.dsl.params.ParamsCollector
|
||||
|
||||
fun ParamsCollector.sortBy(body: OrderBuilder.() -> OrderBuilder): ParamsCollector {
|
||||
internal fun ParamsCollector.sortBy(body: OrderBuilder.() -> OrderBuilder): ParamsCollector {
|
||||
val builder = OrderBuilder()
|
||||
builder.body()
|
||||
this[Order.paramKey] = builder.build()
|
||||
|
|
|
@ -3,7 +3,7 @@ package de.pheerai.rcdbquery.dataMappings.page
|
|||
import de.pheerai.rcdbquery.dataMappings.internal.ParamKey
|
||||
import de.pheerai.rcdbquery.dataMappings.internal.RcdbParamOption
|
||||
|
||||
class Page(override val paramValue: Long) :
|
||||
internal class Page(override val paramValue: Long) :
|
||||
RcdbParamOption<Long> {
|
||||
override val fullName = "The page to show"
|
||||
override val prettyName = "Page"
|
||||
|
|
|
@ -2,7 +2,7 @@ package de.pheerai.rcdbquery.dataMappings.page
|
|||
|
||||
import de.pheerai.rcdbquery.dsl.params.ParamsCollector
|
||||
|
||||
fun ParamsCollector.page(page: Long) = also {
|
||||
internal fun ParamsCollector.page(page: Long) = also {
|
||||
this[Page.paramKey] =
|
||||
Page(page)
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ package de.pheerai.rcdbquery.dataMappings.searchTerm
|
|||
import de.pheerai.rcdbquery.dataMappings.internal.ParamKey
|
||||
import de.pheerai.rcdbquery.dataMappings.internal.RcdbParamOption
|
||||
|
||||
class SearchTerm(override val paramValue: String) :
|
||||
internal class SearchTerm(override val paramValue: String) :
|
||||
RcdbParamOption<String> {
|
||||
override val prettyName = "Search Term"
|
||||
override val fullName = "Search for elements whose name contain this term"
|
||||
|
|
|
@ -2,7 +2,7 @@ package de.pheerai.rcdbquery.dataMappings.searchTerm
|
|||
|
||||
import de.pheerai.rcdbquery.dsl.params.ParamsCollector
|
||||
|
||||
fun ParamsCollector.searchTerm(term: String) = also {
|
||||
internal fun ParamsCollector.searchTerm(term: String) = also {
|
||||
it[SearchTerm.paramKey] = listOf(
|
||||
SearchTerm(term)
|
||||
)
|
||||
|
|
|
@ -4,7 +4,7 @@ import de.pheerai.rcdbquery.dataMappings.internal.ParamKey
|
|||
import de.pheerai.rcdbquery.dataMappings.internal.RcdbParamOption
|
||||
|
||||
@Suppress("unused")
|
||||
enum class SearchType(
|
||||
internal enum class SearchType(
|
||||
override val prettyName: String,
|
||||
override val fullName: String,
|
||||
override val paramValue: Long
|
||||
|
|
|
@ -2,6 +2,6 @@ package de.pheerai.rcdbquery.dataMappings.searchType
|
|||
|
||||
import de.pheerai.rcdbquery.dsl.params.ParamsCollector
|
||||
|
||||
fun ParamsCollector.searchType(searchType: SearchType) = also {
|
||||
internal fun ParamsCollector.searchType(searchType: SearchType) = also {
|
||||
it[SearchType.paramKey] = searchType
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ package de.pheerai.rcdbquery.dataMappings.startsWith
|
|||
import de.pheerai.rcdbquery.dataMappings.internal.ParamKey
|
||||
import de.pheerai.rcdbquery.dataMappings.internal.RcdbParamOption
|
||||
|
||||
class StartsWith(override val paramValue: String) :
|
||||
internal class StartsWith(override val paramValue: String) :
|
||||
RcdbParamOption<String> {
|
||||
override val prettyName = "Starts with"
|
||||
override val fullName = "Name starting with term"
|
||||
|
|
|
@ -2,7 +2,7 @@ package de.pheerai.rcdbquery.dataMappings.startsWith
|
|||
|
||||
import de.pheerai.rcdbquery.dsl.params.ParamsCollector
|
||||
|
||||
fun ParamsCollector.startsWith(term: String) = also {
|
||||
internal fun ParamsCollector.startsWith(term: String) = also {
|
||||
this[StartsWith.paramKey] =
|
||||
StartsWith(term)
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import de.pheerai.rcdbquery.dataMappings.internal.RcdbParamOption
|
|||
import de.pheerai.rcdbquery.dataMappings.internal.StringGeneratable
|
||||
|
||||
@Suppress("unused")
|
||||
enum class Status(
|
||||
internal enum class Status(
|
||||
override val prettyName: String,
|
||||
override val fullName: String,
|
||||
override val paramValue: Long
|
||||
|
|
|
@ -2,7 +2,7 @@ package de.pheerai.rcdbquery.dataMappings.status
|
|||
|
||||
import de.pheerai.rcdbquery.dataMappings.internal.MultiParamBuilder
|
||||
|
||||
class StatusBuilder : MultiParamBuilder<Long, Status>() {
|
||||
internal class StatusBuilder : MultiParamBuilder<Long, Status>() {
|
||||
override fun add(param: Status): StatusBuilder {
|
||||
super.add(param)
|
||||
return this
|
||||
|
|
|
@ -2,7 +2,7 @@ package de.pheerai.rcdbquery.dataMappings.status
|
|||
|
||||
import de.pheerai.rcdbquery.dsl.params.ParamsCollector
|
||||
|
||||
fun ParamsCollector.status(body: StatusBuilder.() -> StatusBuilder): ParamsCollector {
|
||||
private fun ParamsCollector.status(body: StatusBuilder.() -> StatusBuilder): ParamsCollector {
|
||||
val builder = StatusBuilder()
|
||||
builder.body()
|
||||
this[Status.paramKey] = builder.build()
|
||||
|
|
|
@ -3,7 +3,7 @@ package de.pheerai.rcdbquery.dataMappings.thrill
|
|||
import de.pheerai.rcdbquery.dataMappings.internal.RcdbParamOption
|
||||
import de.pheerai.rcdbquery.dataMappings.internal.StringGeneratable
|
||||
|
||||
enum class Thrill(
|
||||
internal enum class Thrill(
|
||||
override val prettyName: String,
|
||||
override val fullName: String,
|
||||
override val paramValue: Long
|
||||
|
|
|
@ -2,7 +2,7 @@ package de.pheerai.rcdbquery.dataMappings.thrill
|
|||
|
||||
import de.pheerai.rcdbquery.dataMappings.internal.MultiParamBuilder
|
||||
|
||||
class ThrillBuilder : MultiParamBuilder<Long, Thrill>() {
|
||||
internal class ThrillBuilder : MultiParamBuilder<Long, Thrill>() {
|
||||
override fun add(param: Thrill): ThrillBuilder {
|
||||
super.add(param)
|
||||
return this
|
||||
|
|
|
@ -2,7 +2,7 @@ package de.pheerai.rcdbquery.dataMappings.thrill
|
|||
|
||||
import de.pheerai.rcdbquery.dsl.params.ParamsCollector
|
||||
|
||||
fun ParamsCollector.thrill(body: ThrillBuilder.() -> ThrillBuilder): ParamsCollector {
|
||||
private fun ParamsCollector.thrill(body: ThrillBuilder.() -> ThrillBuilder): ParamsCollector {
|
||||
val builder = ThrillBuilder()
|
||||
builder.body()
|
||||
this[Thrill.paramKey] = builder.build()
|
||||
|
|
|
@ -3,7 +3,7 @@ package de.pheerai.rcdbquery.dataMappings.type
|
|||
import de.pheerai.rcdbquery.dataMappings.internal.RcdbParamOption
|
||||
import de.pheerai.rcdbquery.dataMappings.internal.StringGeneratable
|
||||
|
||||
enum class Type(
|
||||
internal enum class Type(
|
||||
override val prettyName: String,
|
||||
override val fullName: String,
|
||||
override val paramValue: Long
|
||||
|
|
|
@ -2,7 +2,7 @@ package de.pheerai.rcdbquery.dataMappings.type
|
|||
|
||||
import de.pheerai.rcdbquery.dataMappings.internal.MultiParamBuilder
|
||||
|
||||
class TypeBuilder : MultiParamBuilder<Long, Type>() {
|
||||
internal class TypeBuilder : MultiParamBuilder<Long, Type>() {
|
||||
override fun add(param: Type): TypeBuilder {
|
||||
super.add(param)
|
||||
return this
|
||||
|
|
|
@ -2,7 +2,7 @@ package de.pheerai.rcdbquery.dataMappings.type
|
|||
|
||||
import de.pheerai.rcdbquery.dsl.params.ParamsCollector
|
||||
|
||||
fun ParamsCollector.type(body: TypeBuilder.() -> TypeBuilder): ParamsCollector {
|
||||
private fun ParamsCollector.type(body: TypeBuilder.() -> TypeBuilder): ParamsCollector {
|
||||
val builder = TypeBuilder()
|
||||
builder.body()
|
||||
this[Type.paramKey] = builder.build()
|
||||
|
|
|
@ -3,7 +3,7 @@ package de.pheerai.rcdbquery.dataMappings
|
|||
import de.pheerai.rcdbquery.dataMappings.order.Order
|
||||
import de.pheerai.rcdbquery.dsl.params.ParamsCollector
|
||||
|
||||
const val EXTRA_COLUMNS_ERROR_MESSAGE =
|
||||
public const val EXTRA_COLUMNS_ERROR_MESSAGE: String =
|
||||
"The parameter for extra columns has not yet been discovered (if it even exists). Use multiple values in the `sortBy` param instead (first values take sorting precedence)"
|
||||
|
||||
@Suppress("unused")
|
||||
|
@ -11,7 +11,7 @@ const val EXTRA_COLUMNS_ERROR_MESSAGE =
|
|||
EXTRA_COLUMNS_ERROR_MESSAGE,
|
||||
ReplaceWith("sortBy"), DeprecationLevel.ERROR
|
||||
)
|
||||
fun ParamsCollector.extraColumns(orders: List<Order>): Nothing =
|
||||
internal fun ParamsCollector.extraColumns(orders: List<Order>): Nothing =
|
||||
error(EXTRA_COLUMNS_ERROR_MESSAGE)
|
||||
|
||||
@Suppress("unused")
|
||||
|
@ -19,5 +19,5 @@ fun ParamsCollector.extraColumns(orders: List<Order>): Nothing =
|
|||
EXTRA_COLUMNS_ERROR_MESSAGE,
|
||||
ReplaceWith("sortBy"), DeprecationLevel.ERROR
|
||||
)
|
||||
fun ParamsCollector.extraColumns(vararg orders: Order): Nothing =
|
||||
internal fun ParamsCollector.extraColumns(vararg orders: Order): Nothing =
|
||||
error(EXTRA_COLUMNS_ERROR_MESSAGE)
|
||||
|
|
|
@ -5,7 +5,7 @@ import de.pheerai.rcdbquery.dataMappings.internal.RcdbParamOption
|
|||
import de.pheerai.rcdbquery.dataMappings.internal.StringGeneratable
|
||||
|
||||
@Suppress("unused")
|
||||
enum class Vendor(
|
||||
internal enum class Vendor(
|
||||
override val prettyName: String,
|
||||
override val fullName: String,
|
||||
override val paramValue: Long,
|
||||
|
|
|
@ -2,11 +2,11 @@ package de.pheerai.rcdbquery.dataMappings.vendor
|
|||
|
||||
import de.pheerai.rcdbquery.dataMappings.internal.MultiParamBuilder
|
||||
|
||||
class VendorBuilder : MultiParamBuilder<Long, Vendor>() {
|
||||
internal class VendorBuilder : MultiParamBuilder<Long, Vendor>() {
|
||||
override fun add(param: Vendor): VendorBuilder {
|
||||
super.add(param)
|
||||
return this
|
||||
}
|
||||
|
||||
override fun Vendor.invoke() = add(this)
|
||||
override operator fun Vendor.invoke() = add(this)
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ package de.pheerai.rcdbquery.dataMappings.vendor
|
|||
import de.pheerai.rcdbquery.dsl.params.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 {
|
||||
internal fun ParamsCollector.vendors(body: VendorBuilder.() -> VendorBuilder): ParamsCollector {
|
||||
val builder = VendorBuilder()
|
||||
builder.body()
|
||||
this[Vendor.paramKey] = builder.build()
|
||||
|
|
|
@ -4,7 +4,7 @@ import de.pheerai.rcdbquery.dataMappings.internal.RcdbParamOption
|
|||
import de.pheerai.rcdbquery.dataMappings.searchType.SearchType
|
||||
import de.pheerai.rcdbquery.dsl.RcdbParams
|
||||
|
||||
class ParamsCollector {
|
||||
internal class ParamsCollector {
|
||||
private val multiParams: MutableMap<String, List<RcdbParamOption<Any>>> = mutableMapOf()
|
||||
private val singleParams: MutableMap<String, RcdbParamOption<Any>> = mutableMapOf()
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package de.pheerai.rcdbquery.dsl.params
|
||||
|
||||
sealed class BaseParams<T> {
|
||||
internal sealed class BaseParams<T> {
|
||||
abstract val params: Map<String, T>
|
||||
}
|
||||
|
||||
class MultiParams(override val params: Map<String, List<String>>) : BaseParams<List<String>>()
|
||||
class SingleParams(override val params: Map<String, String>) : BaseParams<String>()
|
||||
internal class MultiParams(override val params: Map<String, List<String>>) : BaseParams<List<String>>()
|
||||
internal class SingleParams(override val params: Map<String, String>) : BaseParams<String>()
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
package de.pheerai.rcdbquery.dsl.params
|
||||
|
||||
class ParamAlreadySetException(message: String) : IllegalArgumentException(message)
|
||||
internal class ParamAlreadySetException(message: String) : IllegalArgumentException(message)
|
||||
|
|
|
@ -4,7 +4,7 @@ import de.pheerai.rcdbquery.dsl.params.MultiParams
|
|||
import de.pheerai.rcdbquery.dsl.params.ParamsCollector
|
||||
import de.pheerai.rcdbquery.dsl.params.SingleParams
|
||||
|
||||
data class RcdbParams(
|
||||
internal data class RcdbParams(
|
||||
val multiParams: MultiParams,
|
||||
val singleParams: SingleParams,
|
||||
) {
|
||||
|
@ -24,10 +24,10 @@ data class RcdbParams(
|
|||
}
|
||||
}
|
||||
|
||||
fun rcdbQuery(body: ParamsCollector.() -> ParamsCollector) =
|
||||
internal fun rcdbQuery(body: ParamsCollector.() -> ParamsCollector) =
|
||||
RcdbUrlQuery("https://www.rcdb.com/r.htm?", rcdbQueryParams(body)).toString()
|
||||
|
||||
data class RcdbUrlQuery(val baseUrl: String, val params: RcdbParams) {
|
||||
private data class RcdbUrlQuery(val baseUrl: String, val params: RcdbParams) {
|
||||
override fun toString(): String {
|
||||
return params.toStrings()
|
||||
.joinToString(prefix = baseUrl, separator = "&")
|
||||
|
@ -37,7 +37,7 @@ data class RcdbUrlQuery(val baseUrl: String, val params: RcdbParams) {
|
|||
/**
|
||||
* Builder for the parameters only (mainly because it might be possilbe in the future to have an API with a POST search object?
|
||||
*/
|
||||
fun rcdbQueryParams(body: ParamsCollector.() -> ParamsCollector): RcdbParams {
|
||||
private fun rcdbQueryParams(body: ParamsCollector.() -> ParamsCollector): RcdbParams {
|
||||
val builder = ParamsCollector()
|
||||
builder.body()
|
||||
return builder.build()
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
module rcdbquery.main {
|
||||
exports de.pheerai.rcdbquery.dataMappings.category;
|
||||
exports de.pheerai.rcdbquery.dataMappings.classification;
|
||||
exports de.pheerai.rcdbquery.dataMappings;
|
||||
exports de.pheerai.rcdbquery.dataMappings.design;
|
||||
exports de.pheerai.rcdbquery.dataMappings.layout;
|
||||
exports de.pheerai.rcdbquery.dataMappings.order;
|
||||
|
@ -16,4 +17,5 @@ module rcdbquery.main {
|
|||
exports de.pheerai.rcdbquery.dsl.params;
|
||||
|
||||
requires kotlin.stdlib;
|
||||
requires java.base;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue