Make API visible again.
This commit is contained in:
parent
00f74792d5
commit
f3944d01d3
37 changed files with 91 additions and 91 deletions
|
@ -2,11 +2,11 @@ package de.pheerai.rcdbquery.dataMappings.category
|
|||
|
||||
import de.pheerai.rcdbquery.dataMappings.internal.MultiParamBuilder
|
||||
|
||||
internal class CategoryBuilder : MultiParamBuilder<Long, Category>() {
|
||||
public class CategoryBuilder : MultiParamBuilder<Long, Category>() {
|
||||
override fun add(param: Category): CategoryBuilder {
|
||||
super.add(param)
|
||||
return this
|
||||
}
|
||||
|
||||
override fun Category.invoke() = add(this)
|
||||
override fun Category.invoke(): CategoryBuilder = add(this)
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package de.pheerai.rcdbquery.dataMappings.category
|
|||
|
||||
import de.pheerai.rcdbquery.dsl.params.ParamsCollector
|
||||
|
||||
private fun ParamsCollector.category(body: CategoryBuilder.() -> CategoryBuilder): ParamsCollector {
|
||||
public 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
|
||||
|
||||
internal enum class Classification(
|
||||
public enum class Classification(
|
||||
override val prettyName: String,
|
||||
override val fullName: String,
|
||||
override val paramValue: Long
|
||||
|
@ -15,8 +15,8 @@ internal enum class Classification(
|
|||
|
||||
constructor(name: String, paramValue: Long) : this(name, name, paramValue)
|
||||
|
||||
companion object: StringGeneratable<Classification> {
|
||||
override fun of(input: String) = values().find { it.fullName == input }
|
||||
override val paramKey = "cs"
|
||||
public companion object: StringGeneratable<Classification> {
|
||||
override fun of(input: String): Classification? = values().find { it.fullName == input }
|
||||
override val paramKey: String = "cs"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,11 +2,11 @@ package de.pheerai.rcdbquery.dataMappings.classification
|
|||
|
||||
import de.pheerai.rcdbquery.dataMappings.internal.MultiParamBuilder
|
||||
|
||||
internal class ClassificationBuilder : MultiParamBuilder<Long, Classification>() {
|
||||
public class ClassificationBuilder : MultiParamBuilder<Long, Classification>() {
|
||||
override fun add(param: Classification): ClassificationBuilder {
|
||||
super.add(param)
|
||||
return this
|
||||
}
|
||||
|
||||
override fun Classification.invoke() = add(this)
|
||||
override fun Classification.invoke(): ClassificationBuilder = add(this)
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package de.pheerai.rcdbquery.dataMappings.classification
|
|||
|
||||
import de.pheerai.rcdbquery.dsl.params.ParamsCollector
|
||||
|
||||
private fun ParamsCollector.classification(body: ClassificationBuilder.() -> ClassificationBuilder): ParamsCollector {
|
||||
public 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
|
||||
|
||||
internal enum class Design(
|
||||
public enum class Design(
|
||||
override val prettyName: String,
|
||||
override val fullName: String,
|
||||
override val paramValue: Long
|
||||
|
@ -20,8 +20,8 @@ internal enum class Design(
|
|||
|
||||
constructor(name: String, paramValue: Long) : this(name, name, paramValue)
|
||||
|
||||
companion object : StringGeneratable<Design> {
|
||||
override val paramKey = "de"
|
||||
public companion object : StringGeneratable<Design> {
|
||||
override val paramKey: String = "de"
|
||||
override fun of(input: String): Design? = when (input) {
|
||||
"Sit Down" -> SIT_DOWN
|
||||
"Inverted" -> INVERTED
|
||||
|
|
|
@ -2,11 +2,11 @@ package de.pheerai.rcdbquery.dataMappings.design
|
|||
|
||||
import de.pheerai.rcdbquery.dataMappings.internal.MultiParamBuilder
|
||||
|
||||
internal class DesignBuilder : MultiParamBuilder<Long, Design>() {
|
||||
public class DesignBuilder : MultiParamBuilder<Long, Design>() {
|
||||
override fun add(param: Design): DesignBuilder {
|
||||
super.add(param)
|
||||
return this
|
||||
}
|
||||
|
||||
override fun Design.invoke() = add(this)
|
||||
override fun Design.invoke(): DesignBuilder = add(this)
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package de.pheerai.rcdbquery.dataMappings.design
|
|||
|
||||
import de.pheerai.rcdbquery.dsl.params.ParamsCollector
|
||||
|
||||
private fun ParamsCollector.design(body: DesignBuilder.() -> DesignBuilder): ParamsCollector {
|
||||
public fun ParamsCollector.design(body: DesignBuilder.() -> DesignBuilder): ParamsCollector {
|
||||
val builder = DesignBuilder()
|
||||
builder.body()
|
||||
this[Design.paramKey] = builder.build()
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package de.pheerai.rcdbquery.dataMappings.internal
|
||||
|
||||
internal abstract class MultiParamBuilder<out U : Any, T : RcdbParamOption<U>> {
|
||||
public abstract class MultiParamBuilder<out U : Any, T : RcdbParamOption<U>> {
|
||||
private val paramList: MutableList<T> = mutableListOf()
|
||||
|
||||
open fun add(param: T): MultiParamBuilder<U, T> {
|
||||
public open fun add(param: T): MultiParamBuilder<U, T> {
|
||||
paramList.add(param)
|
||||
return this
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ internal abstract class MultiParamBuilder<out U : Any, T : RcdbParamOption<U>> {
|
|||
return this
|
||||
}
|
||||
|
||||
fun build() = paramList.toList()
|
||||
public fun build(): List<T> = paramList.toList()
|
||||
|
||||
abstract operator fun T.invoke(): MultiParamBuilder<U, T>
|
||||
public abstract operator fun T.invoke(): MultiParamBuilder<U, T>
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package de.pheerai.rcdbquery.dataMappings.internal
|
||||
|
||||
internal interface RcdbParamOption<out T> {
|
||||
val prettyName: String
|
||||
val fullName: String
|
||||
val paramValue: T
|
||||
public interface RcdbParamOption<out T> {
|
||||
public val prettyName: String
|
||||
public val fullName: String
|
||||
public val paramValue: 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
|
||||
|
||||
internal enum class Layout(
|
||||
public enum class Layout(
|
||||
override val prettyName: String,
|
||||
override val fullName: String,
|
||||
override val paramValue: Long
|
||||
|
@ -37,8 +37,8 @@ internal enum class Layout(
|
|||
|
||||
constructor(name: String, paramValue: Long) : this(name, name, paramValue)
|
||||
|
||||
companion object : StringGeneratable<Layout> {
|
||||
override val paramKey = "lo"
|
||||
public companion object : StringGeneratable<Layout> {
|
||||
override val paramKey: String = "lo"
|
||||
|
||||
override fun of(input: String): Layout? = values().find { input == it.fullName }
|
||||
}
|
||||
|
|
|
@ -2,11 +2,11 @@ package de.pheerai.rcdbquery.dataMappings.layout
|
|||
|
||||
import de.pheerai.rcdbquery.dataMappings.internal.MultiParamBuilder
|
||||
|
||||
internal class LayoutBuilder : MultiParamBuilder<Long, Layout>() {
|
||||
public class LayoutBuilder : MultiParamBuilder<Long, Layout>() {
|
||||
override fun add(param: Layout): LayoutBuilder {
|
||||
super.add(param)
|
||||
return this
|
||||
}
|
||||
|
||||
override operator fun Layout.invoke() = add(this)
|
||||
override operator fun Layout.invoke(): LayoutBuilder = add(this)
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package de.pheerai.rcdbquery.dataMappings.layout
|
|||
|
||||
import de.pheerai.rcdbquery.dsl.params.ParamsCollector
|
||||
|
||||
private fun ParamsCollector.layout(body: LayoutBuilder.() -> LayoutBuilder): ParamsCollector {
|
||||
public fun ParamsCollector.layout(body: LayoutBuilder.() -> LayoutBuilder): ParamsCollector {
|
||||
val builder = LayoutBuilder()
|
||||
with(Layout) {
|
||||
builder.body()
|
||||
|
|
|
@ -5,7 +5,7 @@ import de.pheerai.rcdbquery.dataMappings.internal.RcdbParamOption
|
|||
import de.pheerai.rcdbquery.dataMappings.internal.RelevantForAll
|
||||
|
||||
@Suppress("unused")
|
||||
internal enum class Order(
|
||||
public enum class Order(
|
||||
override val prettyName: String,
|
||||
override val fullName: String,
|
||||
override val paramValue: Long,
|
||||
|
@ -49,7 +49,7 @@ internal enum class Order(
|
|||
|
||||
constructor(name: String, paramId: Long) : this(name, name, paramId)
|
||||
|
||||
companion object : ParamKey {
|
||||
override val paramKey = "order"
|
||||
public companion object : ParamKey {
|
||||
override val paramKey: String = "order"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package de.pheerai.rcdbquery.dataMappings.order
|
|||
|
||||
import de.pheerai.rcdbquery.dataMappings.internal.MultiParamBuilder
|
||||
|
||||
internal class OrderBuilder : MultiParamBuilder<Long, Order>() {
|
||||
public class OrderBuilder : MultiParamBuilder<Long, Order>() {
|
||||
override fun add(param: Order): OrderBuilder {
|
||||
super.add(param)
|
||||
return this
|
||||
|
@ -18,6 +18,6 @@ internal class OrderBuilder : MultiParamBuilder<Long, Order>() {
|
|||
return this
|
||||
}
|
||||
|
||||
override operator fun Order.invoke() = add(this)
|
||||
fun allRelevant() = this.addAll(Order.values().filter { it.relevantForAll })
|
||||
override operator fun Order.invoke(): OrderBuilder = add(this)
|
||||
public fun allRelevant(): OrderBuilder = this.addAll(Order.values().filter { it.relevantForAll })
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package de.pheerai.rcdbquery.dataMappings.order
|
|||
|
||||
import de.pheerai.rcdbquery.dsl.params.ParamsCollector
|
||||
|
||||
internal fun ParamsCollector.sortBy(body: OrderBuilder.() -> OrderBuilder): ParamsCollector {
|
||||
public fun ParamsCollector.sortBy(body: OrderBuilder.() -> OrderBuilder): ParamsCollector {
|
||||
val builder = OrderBuilder()
|
||||
builder.body()
|
||||
this[Order.paramKey] = builder.build()
|
||||
|
|
|
@ -2,7 +2,7 @@ package de.pheerai.rcdbquery.dataMappings.page
|
|||
|
||||
import de.pheerai.rcdbquery.dsl.params.ParamsCollector
|
||||
|
||||
internal fun ParamsCollector.page(page: Long) = also {
|
||||
public fun ParamsCollector.page(page: Long): ParamsCollector = also {
|
||||
this[Page.paramKey] =
|
||||
Page(page)
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package de.pheerai.rcdbquery.dataMappings.searchTerm
|
|||
|
||||
import de.pheerai.rcdbquery.dsl.params.ParamsCollector
|
||||
|
||||
internal fun ParamsCollector.searchTerm(term: String) = also {
|
||||
public fun ParamsCollector.searchTerm(term: String): ParamsCollector = 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")
|
||||
internal enum class SearchType(
|
||||
public enum class SearchType(
|
||||
override val prettyName: String,
|
||||
override val fullName: String,
|
||||
override val paramValue: Long
|
||||
|
@ -15,7 +15,7 @@ internal enum class SearchType(
|
|||
PERSON("Person", "Search for a person (designer, engineer,...)", 13)
|
||||
;
|
||||
|
||||
companion object: ParamKey {
|
||||
override val paramKey = "ot"
|
||||
public companion object: ParamKey {
|
||||
override val paramKey: String = "ot"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,6 @@ package de.pheerai.rcdbquery.dataMappings.searchType
|
|||
|
||||
import de.pheerai.rcdbquery.dsl.params.ParamsCollector
|
||||
|
||||
internal fun ParamsCollector.searchType(searchType: SearchType) = also {
|
||||
public fun ParamsCollector.searchType(searchType: SearchType): ParamsCollector = also {
|
||||
it[SearchType.paramKey] = searchType
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package de.pheerai.rcdbquery.dataMappings.startsWith
|
|||
|
||||
import de.pheerai.rcdbquery.dsl.params.ParamsCollector
|
||||
|
||||
internal fun ParamsCollector.startsWith(term: String) = also {
|
||||
public fun ParamsCollector.startsWith(term: String): ParamsCollector = 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")
|
||||
internal enum class Status(
|
||||
public enum class Status(
|
||||
override val prettyName: String,
|
||||
override val fullName: String,
|
||||
override val paramValue: Long
|
||||
|
@ -18,10 +18,10 @@ internal enum class Status(
|
|||
|
||||
constructor(name: String, paramId: Long) : this(name, name, paramId)
|
||||
|
||||
companion object: StringGeneratable<Status> {
|
||||
override val paramKey = "st"
|
||||
public companion object: StringGeneratable<Status> {
|
||||
override val paramKey: String = "st"
|
||||
|
||||
override fun of(input: String) = when (input) {
|
||||
override fun of(input: String): Status? = when (input) {
|
||||
"SBNO" -> SBNO
|
||||
"Operating" -> OPERATING
|
||||
"Under Construction" -> UNDER_CONSTRUCTION
|
||||
|
|
|
@ -2,11 +2,11 @@ package de.pheerai.rcdbquery.dataMappings.status
|
|||
|
||||
import de.pheerai.rcdbquery.dataMappings.internal.MultiParamBuilder
|
||||
|
||||
internal class StatusBuilder : MultiParamBuilder<Long, Status>() {
|
||||
public class StatusBuilder : MultiParamBuilder<Long, Status>() {
|
||||
override fun add(param: Status): StatusBuilder {
|
||||
super.add(param)
|
||||
return this
|
||||
}
|
||||
|
||||
override fun Status.invoke() = add(this)
|
||||
override fun Status.invoke(): StatusBuilder = add(this)
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package de.pheerai.rcdbquery.dataMappings.status
|
|||
|
||||
import de.pheerai.rcdbquery.dsl.params.ParamsCollector
|
||||
|
||||
private fun ParamsCollector.status(body: StatusBuilder.() -> StatusBuilder): ParamsCollector {
|
||||
public 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
|
||||
|
||||
internal enum class Thrill(
|
||||
public enum class Thrill(
|
||||
override val prettyName: String,
|
||||
override val fullName: String,
|
||||
override val paramValue: Long
|
||||
|
@ -16,8 +16,8 @@ internal enum class Thrill(
|
|||
|
||||
constructor(name: String, paramValue: Long) : this(name, name, paramValue)
|
||||
|
||||
companion object : StringGeneratable<Thrill> {
|
||||
override val paramKey = "sc"
|
||||
public companion object : StringGeneratable<Thrill> {
|
||||
override val paramKey: String = "sc"
|
||||
|
||||
override fun of(input: String): Thrill? = when (input) {
|
||||
"Kiddie" -> KIDDIE
|
||||
|
|
|
@ -2,11 +2,11 @@ package de.pheerai.rcdbquery.dataMappings.thrill
|
|||
|
||||
import de.pheerai.rcdbquery.dataMappings.internal.MultiParamBuilder
|
||||
|
||||
internal class ThrillBuilder : MultiParamBuilder<Long, Thrill>() {
|
||||
public class ThrillBuilder : MultiParamBuilder<Long, Thrill>() {
|
||||
override fun add(param: Thrill): ThrillBuilder {
|
||||
super.add(param)
|
||||
return this
|
||||
}
|
||||
|
||||
override fun Thrill.invoke() = add(this)
|
||||
override fun Thrill.invoke(): ThrillBuilder = add(this)
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package de.pheerai.rcdbquery.dataMappings.thrill
|
|||
|
||||
import de.pheerai.rcdbquery.dsl.params.ParamsCollector
|
||||
|
||||
private fun ParamsCollector.thrill(body: ThrillBuilder.() -> ThrillBuilder): ParamsCollector {
|
||||
public 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
|
||||
|
||||
internal enum class Type(
|
||||
public enum class Type(
|
||||
override val prettyName: String,
|
||||
override val fullName: String,
|
||||
override val paramValue: Long
|
||||
|
@ -14,10 +14,10 @@ internal enum class Type(
|
|||
|
||||
constructor(name: String, paramValue: Long): this(name, name, paramValue)
|
||||
|
||||
companion object: StringGeneratable<Type> {
|
||||
override val paramKey = "ty"
|
||||
public companion object: StringGeneratable<Type> {
|
||||
override val paramKey: String = "ty"
|
||||
|
||||
override fun of(input: String) = when(input) {
|
||||
override fun of(input: String): Type? = when(input) {
|
||||
"Steel" -> STEEL
|
||||
"Wood" -> WOOD
|
||||
else -> null
|
||||
|
|
|
@ -2,11 +2,11 @@ package de.pheerai.rcdbquery.dataMappings.type
|
|||
|
||||
import de.pheerai.rcdbquery.dataMappings.internal.MultiParamBuilder
|
||||
|
||||
internal class TypeBuilder : MultiParamBuilder<Long, Type>() {
|
||||
public class TypeBuilder : MultiParamBuilder<Long, Type>() {
|
||||
override fun add(param: Type): TypeBuilder {
|
||||
super.add(param)
|
||||
return this
|
||||
}
|
||||
|
||||
override fun Type.invoke() = add(this)
|
||||
override fun Type.invoke(): TypeBuilder = add(this)
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package de.pheerai.rcdbquery.dataMappings.type
|
|||
|
||||
import de.pheerai.rcdbquery.dsl.params.ParamsCollector
|
||||
|
||||
private fun ParamsCollector.type(body: TypeBuilder.() -> TypeBuilder): ParamsCollector {
|
||||
public fun ParamsCollector.type(body: TypeBuilder.() -> TypeBuilder): ParamsCollector {
|
||||
val builder = TypeBuilder()
|
||||
builder.body()
|
||||
this[Type.paramKey] = builder.build()
|
||||
|
|
|
@ -11,7 +11,7 @@ public const val EXTRA_COLUMNS_ERROR_MESSAGE: String =
|
|||
EXTRA_COLUMNS_ERROR_MESSAGE,
|
||||
ReplaceWith("sortBy"), DeprecationLevel.ERROR
|
||||
)
|
||||
internal fun ParamsCollector.extraColumns(orders: List<Order>): Nothing =
|
||||
public fun ParamsCollector.extraColumns(orders: List<Order>): Nothing =
|
||||
error(EXTRA_COLUMNS_ERROR_MESSAGE)
|
||||
|
||||
@Suppress("unused")
|
||||
|
@ -19,5 +19,5 @@ internal fun ParamsCollector.extraColumns(orders: List<Order>): Nothing =
|
|||
EXTRA_COLUMNS_ERROR_MESSAGE,
|
||||
ReplaceWith("sortBy"), DeprecationLevel.ERROR
|
||||
)
|
||||
internal fun ParamsCollector.extraColumns(vararg orders: Order): Nothing =
|
||||
public 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")
|
||||
internal enum class Vendor(
|
||||
public enum class Vendor(
|
||||
override val prettyName: String,
|
||||
override val fullName: String,
|
||||
override val paramValue: Long,
|
||||
|
@ -249,11 +249,11 @@ internal enum class Vendor(
|
|||
|
||||
constructor(name: String, paramId: Long) : this(name, name, paramId)
|
||||
|
||||
companion object : StringGeneratable<Vendor> {
|
||||
override val paramKey = "mk"
|
||||
override fun of(input: String) = values().find { input == it.fullName }
|
||||
public companion object : StringGeneratable<Vendor> {
|
||||
override val paramKey: String = "mk"
|
||||
override fun of(input: String): Vendor? = values().find { input == it.fullName }
|
||||
|
||||
fun searchByName(name: String): List<Vendor> {
|
||||
public fun searchByName(name: String): List<Vendor> {
|
||||
val searchName = name.toLowerCase()
|
||||
return values()
|
||||
.filter {
|
||||
|
|
|
@ -2,11 +2,11 @@ package de.pheerai.rcdbquery.dataMappings.vendor
|
|||
|
||||
import de.pheerai.rcdbquery.dataMappings.internal.MultiParamBuilder
|
||||
|
||||
internal class VendorBuilder : MultiParamBuilder<Long, Vendor>() {
|
||||
public class VendorBuilder : MultiParamBuilder<Long, Vendor>() {
|
||||
override fun add(param: Vendor): VendorBuilder {
|
||||
super.add(param)
|
||||
return this
|
||||
}
|
||||
|
||||
override operator fun Vendor.invoke() = add(this)
|
||||
override operator fun Vendor.invoke(): VendorBuilder = 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"
|
||||
internal fun ParamsCollector.vendors(body: VendorBuilder.() -> VendorBuilder): ParamsCollector {
|
||||
public fun ParamsCollector.vendors(body: VendorBuilder.() -> VendorBuilder): ParamsCollector {
|
||||
val builder = VendorBuilder()
|
||||
builder.body()
|
||||
this[Vendor.paramKey] = builder.build()
|
||||
|
|
|
@ -4,11 +4,11 @@ import de.pheerai.rcdbquery.dataMappings.internal.RcdbParamOption
|
|||
import de.pheerai.rcdbquery.dataMappings.searchType.SearchType
|
||||
import de.pheerai.rcdbquery.dsl.RcdbParams
|
||||
|
||||
internal class ParamsCollector {
|
||||
public class ParamsCollector {
|
||||
private val multiParams: MutableMap<String, List<RcdbParamOption<Any>>> = mutableMapOf()
|
||||
private val singleParams: MutableMap<String, RcdbParamOption<Any>> = mutableMapOf()
|
||||
|
||||
fun build() = RcdbParams(buildMulti(), buildSingle())
|
||||
public fun build(): RcdbParams = RcdbParams(buildMulti(), buildSingle())
|
||||
|
||||
/**
|
||||
* Creates the Query Params from this builder.
|
||||
|
@ -27,11 +27,11 @@ internal class ParamsCollector {
|
|||
.mapValues { e -> e.value.paramValue.toString() }
|
||||
.let { SingleParams(it) }
|
||||
|
||||
operator fun set(paramName: String, options: List<RcdbParamOption<Any>>) {
|
||||
public operator fun set(paramName: String, options: List<RcdbParamOption<Any>>) {
|
||||
this.multiParams[paramName] = options
|
||||
}
|
||||
|
||||
operator fun set(paramName: String, option: RcdbParamOption<Any>) {
|
||||
public operator fun set(paramName: String, option: RcdbParamOption<Any>) {
|
||||
if (paramName !in singleParams && paramName !in multiParams) {
|
||||
this.singleParams[paramName] = option
|
||||
} else {
|
||||
|
@ -39,10 +39,10 @@ internal class ParamsCollector {
|
|||
}
|
||||
}
|
||||
|
||||
fun getSingle(paramName: String) = this.multiParams[paramName] ?: this.singleParams[paramName]
|
||||
fun getMulti(paramName: String) = this.multiParams[paramName]
|
||||
public fun getSingle(paramName: String): Any? = this.multiParams[paramName] ?: this.singleParams[paramName]
|
||||
public fun getMulti(paramName: String): List<RcdbParamOption<Any>>? = this.multiParams[paramName]
|
||||
|
||||
fun keys() = this.multiKeys().plus(singleKeys())
|
||||
public fun keys(): Set<String> = this.multiKeys().plus(singleKeys())
|
||||
private fun multiKeys() = this.multiParams.keys.toSet()
|
||||
private fun singleKeys() = this.singleParams.keys.toSet()
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package de.pheerai.rcdbquery.dsl.params
|
||||
|
||||
internal sealed class BaseParams<T> {
|
||||
abstract val params: Map<String, T>
|
||||
public sealed class BaseParams<T> {
|
||||
public abstract val params: Map<String, T>
|
||||
}
|
||||
|
||||
internal class MultiParams(override val params: Map<String, List<String>>) : BaseParams<List<String>>()
|
||||
internal class SingleParams(override val params: Map<String, String>) : BaseParams<String>()
|
||||
public class MultiParams(override val params: Map<String, List<String>>) : BaseParams<List<String>>()
|
||||
public class SingleParams(override val params: Map<String, String>) : BaseParams<String>()
|
||||
|
|
|
@ -4,11 +4,11 @@ import de.pheerai.rcdbquery.dsl.params.MultiParams
|
|||
import de.pheerai.rcdbquery.dsl.params.ParamsCollector
|
||||
import de.pheerai.rcdbquery.dsl.params.SingleParams
|
||||
|
||||
internal data class RcdbParams(
|
||||
val multiParams: MultiParams,
|
||||
val singleParams: SingleParams,
|
||||
public data class RcdbParams(
|
||||
private val multiParams: MultiParams,
|
||||
private val singleParams: SingleParams,
|
||||
) {
|
||||
fun toStrings(): List<String> {
|
||||
public fun toStrings(): List<String> {
|
||||
val multiParamSequence: Sequence<Pair<String, String>> = this.multiParams
|
||||
.params
|
||||
.mapValues { it.value.joinToString(separator = ",") }
|
||||
|
@ -24,7 +24,7 @@ internal data class RcdbParams(
|
|||
}
|
||||
}
|
||||
|
||||
internal fun rcdbQuery(body: ParamsCollector.() -> ParamsCollector) =
|
||||
public fun rcdbQuery(body: ParamsCollector.() -> ParamsCollector): String =
|
||||
RcdbUrlQuery("https://www.rcdb.com/r.htm?", rcdbQueryParams(body)).toString()
|
||||
|
||||
private data class RcdbUrlQuery(val baseUrl: String, val params: RcdbParams) {
|
||||
|
@ -35,7 +35,7 @@ private 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?
|
||||
* Builder for the parameters only (mainly because it might be possible in the future to have an API with a POST search object?
|
||||
*/
|
||||
private fun rcdbQueryParams(body: ParamsCollector.() -> ParamsCollector): RcdbParams {
|
||||
val builder = ParamsCollector()
|
||||
|
|
Loading…
Reference in a new issue