![JAR search and dependency download from the Maven repository](/logo.png)
commonMain.com.harmony.kotlin.data.query.Query.kt Maven / Gradle / Ivy
package com.harmony.kotlin.data.query
// Queries
open class Query
object VoidQuery : Query()
// Single object query
open class ObjectQuery(val value: T) : Query()
// Collection objects query
open class ObjectsQuery(val values: Collection) : Query()
// Generic all object query supporting key value
open class AllObjectsQuery : KeyQuery("all-objects-key")
open class IdQuery(val identifier: T) : KeyQuery(identifier.toString())
open class IntegerIdQuery(val id: Int) : IdQuery(id)
open class StringIdQuery(val id: String) : IdQuery(id)
open class IdsQuery(val identifiers: Collection) : KeyQuery(identifiers.toString())
open class IntegerIdsQuery(val ids: Collection) : IdsQuery(ids)
open class PaginationQuery(identifier: String) : KeyQuery(identifier)
open class PaginationOffsetLimitQuery(identifier: String, val offset: Int, val limit: Int) : PaginationQuery("$identifier-$offset-$limit")
// Key value queries
open class KeyQuery(val key: String /* key associated to the query */) : Query()
// Extensions
inline fun IdQuery<*>.asTyped(): IdQuery? = (this.identifier as? T)?.let { IdQuery(it) }
// inline fun KeyQuery<*>.asTyped(): KeyQuery? = (this.key as? T)?.let { KeyQuery(it) }
// fun KeyQuery<*>.isTyped(type: Class): Boolean {
// return type.isAssignableFrom(this.key!!::class.java.componentType)
// }
© 2015 - 2025 Weber Informatics LLC | Privacy Policy