All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jooq.kotlin.Extensions.kt Maven / Gradle / Ivy

There is a newer version: 3.19.11
Show newest version
package org.jooq.kotlin

import org.jooq.*
import org.jooq.impl.DSL.*
import java.util.stream.Collector

// ----------------------------------------------------------------------------
// Extensions to collect Field> into other types
// ----------------------------------------------------------------------------

fun  Field>.collecting(collector: Collector): Field = convertFrom { it.collect(collector) }

inline fun  Field>>.intoArray(): Field> = collecting(Records.intoArray(E::class.java))

inline fun  Field>.intoArray(noinline mapper: (R) -> E): Field> = collecting(Records.intoArray(E::class.java, mapper))

fun > Field>.intoGroups(): Field>> = collecting(Records.intoGroups())

fun  Field>.intoGroups(keyMapper: (R) -> K): Field>> = collecting(Records.intoGroups(keyMapper))

fun  Field>.intoGroups(keyMapper: (R) -> K, valueMapper: (R) -> V): Field>> = collecting(Records.intoGroups(keyMapper, valueMapper))

fun > Field>.intoList(): Field> = collecting(Records.intoList())

fun  Field>.intoList(mapper: (R) -> E): Field> = collecting(Records.intoList(mapper))

fun  Field>>.intoMap(): Field> = collecting(Records.intoMap())

fun  Field>.intoMap(keyMapper: (R) -> K): Field> = collecting(Records.intoMap(keyMapper))

fun  Field>.intoMap(keyMapper: (R) -> K, valueMapper: (R) -> V): Field> = collecting(Records.intoMap(keyMapper, valueMapper))

fun  Field>.intoResultGroups(keyMapper: (R) -> K): Field>> = collecting(Records.intoResultGroups(keyMapper))

fun  Field>.intoResultGroups(keyMapper: (R) -> K, valueMapper: (R) -> V): Field>> = collecting(Records.intoResultGroups(keyMapper, valueMapper))

fun > Field>.intoSet(): Field> = collecting(Records.intoSet())

fun  Field>.intoSet(mapper: (R) -> E): Field> = collecting(Records.intoSet(mapper))



// ----------------------------------------------------------------------------
// Extensions to map Field> to more convenient Field>
// As well as Field to Field
// ----------------------------------------------------------------------------

// [jooq-tools] START [mapping]

@JvmName("mappingRecord")
fun  Field>.mapping(f: Function1): Field = convertFrom { Records.mapping(f).apply(it) }

@JvmName("mappingRecord")
fun  Field>.mapping(f: Function2): Field = convertFrom { Records.mapping(f).apply(it) }

@JvmName("mappingRecord")
fun  Field>.mapping(f: Function3): Field = convertFrom { Records.mapping(f).apply(it) }

@JvmName("mappingRecord")
fun  Field>.mapping(f: Function4): Field = convertFrom { Records.mapping(f).apply(it) }

@JvmName("mappingRecord")
fun  Field>.mapping(f: Function5): Field = convertFrom { Records.mapping(f).apply(it) }

@JvmName("mappingRecord")
fun  Field>.mapping(f: Function6): Field = convertFrom { Records.mapping(f).apply(it) }

@JvmName("mappingRecord")
fun  Field>.mapping(f: Function7): Field = convertFrom { Records.mapping(f).apply(it) }

@JvmName("mappingRecord")
fun  Field>.mapping(f: Function8): Field = convertFrom { Records.mapping(f).apply(it) }

@JvmName("mappingRecord")
fun  Field>.mapping(f: Function9): Field = convertFrom { Records.mapping(f).apply(it) }

@JvmName("mappingRecord")
fun  Field>.mapping(f: Function10): Field = convertFrom { Records.mapping(f).apply(it) }

@JvmName("mappingRecord")
fun  Field>.mapping(f: Function11): Field = convertFrom { Records.mapping(f).apply(it) }

@JvmName("mappingRecord")
fun  Field>.mapping(f: Function12): Field = convertFrom { Records.mapping(f).apply(it) }

@JvmName("mappingRecord")
fun  Field>.mapping(f: Function13): Field = convertFrom { Records.mapping(f).apply(it) }

@JvmName("mappingRecord")
fun  Field>.mapping(f: Function14): Field = convertFrom { Records.mapping(f).apply(it) }

@JvmName("mappingRecord")
fun  Field>.mapping(f: Function15): Field = convertFrom { Records.mapping(f).apply(it) }

@JvmName("mappingRecord")
fun  Field>.mapping(f: Function16): Field = convertFrom { Records.mapping(f).apply(it) }

@JvmName("mappingRecord")
fun  Field>.mapping(f: Function17): Field = convertFrom { Records.mapping(f).apply(it) }

@JvmName("mappingRecord")
fun  Field>.mapping(f: Function18): Field = convertFrom { Records.mapping(f).apply(it) }

@JvmName("mappingRecord")
fun  Field>.mapping(f: Function19): Field = convertFrom { Records.mapping(f).apply(it) }

@JvmName("mappingRecord")
fun  Field>.mapping(f: Function20): Field = convertFrom { Records.mapping(f).apply(it) }

@JvmName("mappingRecord")
fun  Field>.mapping(f: Function21): Field = convertFrom { Records.mapping(f).apply(it) }

@JvmName("mappingRecord")
fun  Field>.mapping(f: Function22): Field = convertFrom { Records.mapping(f).apply(it) }

fun  Field>>.mapping(f: Function1): Field> = convertFrom { it.map(Records.mapping(f)) }

fun  Field>>.mapping(f: Function2): Field> = convertFrom { it.map(Records.mapping(f)) }

fun  Field>>.mapping(f: Function3): Field> = convertFrom { it.map(Records.mapping(f)) }

fun  Field>>.mapping(f: Function4): Field> = convertFrom { it.map(Records.mapping(f)) }

fun  Field>>.mapping(f: Function5): Field> = convertFrom { it.map(Records.mapping(f)) }

fun  Field>>.mapping(f: Function6): Field> = convertFrom { it.map(Records.mapping(f)) }

fun  Field>>.mapping(f: Function7): Field> = convertFrom { it.map(Records.mapping(f)) }

fun  Field>>.mapping(f: Function8): Field> = convertFrom { it.map(Records.mapping(f)) }

fun  Field>>.mapping(f: Function9): Field> = convertFrom { it.map(Records.mapping(f)) }

fun  Field>>.mapping(f: Function10): Field> = convertFrom { it.map(Records.mapping(f)) }

fun  Field>>.mapping(f: Function11): Field> = convertFrom { it.map(Records.mapping(f)) }

fun  Field>>.mapping(f: Function12): Field> = convertFrom { it.map(Records.mapping(f)) }

fun  Field>>.mapping(f: Function13): Field> = convertFrom { it.map(Records.mapping(f)) }

fun  Field>>.mapping(f: Function14): Field> = convertFrom { it.map(Records.mapping(f)) }

fun  Field>>.mapping(f: Function15): Field> = convertFrom { it.map(Records.mapping(f)) }

fun  Field>>.mapping(f: Function16): Field> = convertFrom { it.map(Records.mapping(f)) }

fun  Field>>.mapping(f: Function17): Field> = convertFrom { it.map(Records.mapping(f)) }

fun  Field>>.mapping(f: Function18): Field> = convertFrom { it.map(Records.mapping(f)) }

fun  Field>>.mapping(f: Function19): Field> = convertFrom { it.map(Records.mapping(f)) }

fun  Field>>.mapping(f: Function20): Field> = convertFrom { it.map(Records.mapping(f)) }

fun  Field>>.mapping(f: Function21): Field> = convertFrom { it.map(Records.mapping(f)) }

fun  Field>>.mapping(f: Function22): Field> = convertFrom { it.map(Records.mapping(f)) }

// [jooq-tools] END [mapping]

// ----------------------------------------------------------------------------
// Extensions to make Field a Condition
// ----------------------------------------------------------------------------

@Support
fun Field.and(other: Condition): Condition = condition(this).and(other)

@Support
fun Field.and(other: Field): Condition = condition(this).and(other)

@Support
@PlainSQL
fun Field.and(sql: SQL): Condition = condition(this).and(sql)

@Support
@PlainSQL
fun Field.and(sql: String): Condition = condition(this).and(sql)

@Support
@PlainSQL
fun Field.and(sql: String, vararg bindings: Any): Condition = condition(this).and(sql, bindings)

@Support
@PlainSQL
fun Field.and(sql: String, vararg parts: QueryPart): Condition = condition(this).and(sql, parts)

@Support
fun Field.andNot(other: Condition): Condition = condition(this).andNot(other)

@Support
fun Field.andNot(other: Field): Condition = condition(this).andNot(other)

@Support
fun Field.andExists(select: Select<*>): Condition = condition(this).andExists(select)

@Support
fun Field.andNotExists(select: Select<*>): Condition = condition(this).andNotExists(select)

@Support
fun Field.or(other: Condition): Condition = condition(this).or(other)

@Support
fun Field.or(other: Field): Condition = condition(this).or(other)

@Support
@PlainSQL
fun Field.or(sql: SQL): Condition = condition(this).or(sql)

@Support
@PlainSQL
fun Field.or(sql: String): Condition = condition(this).or(sql)

@Support
@PlainSQL
fun Field.or(sql: String, vararg bindings: Any): Condition = condition(this).or(sql)

@Support
@PlainSQL
fun Field.or(sql: String, vararg parts: QueryPart): Condition = condition(this).or(sql, parts)

@Support
fun Field.orNot(other: Condition): Condition = condition(this).orNot(other)

@Support
fun Field.orNot(other: Field): Condition = condition(this).orNot(other)

@Support
fun Field.orExists(select: Select<*>): Condition = condition(this).orExists(select)

@Support
fun Field.orNotExists(select: Select<*>): Condition = condition(this).orNotExists(select)

@Support
fun Field.not(): Condition = condition(this).not()


// ----------------------------------------------------------------------------
// Extensions to extract fields from Tables
// ----------------------------------------------------------------------------

@Support
operator fun TableLike<*>.get(index: Int) = this.field(index)

@Support
operator fun TableLike<*>.get(name: Name) = this.field(name)

@Support
operator fun TableLike<*>.get(name: String) = this.field(name)

@Support
operator fun  TableLike<*>.get(field: Field) = this.field(field)

// ----------------------------------------------------------------------------
// Extensions to make Field aware of its being an array
// ----------------------------------------------------------------------------

@Support
operator fun  Field>.get(index: Int) = arrayGet(this, index)

@Support
operator fun  Field>.get(index: Field) = arrayGet(this, index)

// ----------------------------------------------------------------------------
// Extensions to make Select> a scalar subquery of type Field
// ----------------------------------------------------------------------------

@Support
fun  Select>.`as`(alias: String): Field = field(this).`as`(alias)

@Support
fun  Select>.`as`(alias: Name): Field = field(this).`as`(alias)

@Support
fun  Select>.`as`(alias: Field<*>): Field = field(this).`as`(alias)

@Support
fun  Select>.eq(value: T): Condition = field(this).eq(value)

@Support
fun  Select>.eq(value: Field): Condition = field(this).eq(value)

@Support
fun  Select>.equal(value: T): Condition = field(this).equal(value)

@Support
fun  Select>.equal(value: Field): Condition = field(this).equal(value)

@Support
fun  Select>.ne(value: T): Condition = field(this).ne(value)

@Support
fun  Select>.ne(value: Field): Condition = field(this).ne(value)

@Support
fun  Select>.notEqual(value: T): Condition = field(this).notEqual(value)

@Support
fun  Select>.notEqual(value: Field): Condition = field(this).notEqual(value)

@Support
fun  Select>.gt(value: T): Condition = field(this).gt(value)

@Support
fun  Select>.gt(value: Field): Condition = field(this).gt(value)

@Support
fun  Select>.greaterThan(value: T): Condition = field(this).greaterThan(value)

@Support
fun  Select>.greaterThan(value: Field): Condition = field(this).greaterThan(value)

@Support
fun  Select>.ge(value: T): Condition = field(this).ge(value)

@Support
fun  Select>.ge(value: Field): Condition = field(this).ge(value)

@Support
fun  Select>.greaterOrEqual(value: T): Condition = field(this).greaterOrEqual(value)

@Support
fun  Select>.greaterOrEqual(value: Field): Condition =
        field(this).greaterOrEqual(value)

@Support
fun  Select>.lt(value: T): Condition = field(this).lt(value)

@Support
fun  Select>.lt(value: Field): Condition = field(this).lt(value)

@Support
fun  Select>.lessThan(value: T): Condition = field(this).lessThan(value)

@Support
fun  Select>.lessThan(value: Field): Condition = field(this).lessThan(value)

@Support
fun  Select>.le(value: T): Condition = field(this).le(value)

@Support
fun  Select>.le(value: Field): Condition = field(this).le(value)

@Support
fun  Select>.lessOrEqual(value: T): Condition = field(this).lessOrEqual(value)

@Support
fun  Select>.lessOrEqual(value: Field): Condition = field(this).lessOrEqual(value)

@Support
fun  Select>.asc(): SortField = field(this).asc()

@Support
fun  Select>.desc(): SortField = field(this).desc()

@Support
fun  Select>.`in`(values: Collection<*>): Condition = field(this).`in`(values)

@Support
fun  Select>.`in`(values: Result>): Condition = field(this).`in`(values)

@Support
fun  Select>.`in`(vararg values: T): Condition = field(this).`in`(values.asList())

@Support
fun  Select>.`in`(vararg values: Field<*>): Condition = field(this).`in`(values.asList())

@Support
fun  Select>.notIn(values: Collection<*>): Condition = field(this).notIn(values)

@Support
fun  Select>.notIn(values: Result>): Condition = field(this).notIn(values)

@Support
fun  Select>.notIn(vararg values: T): Condition = field(this).notIn(values.asList())

@Support
fun  Select>.notIn(vararg values: Field<*>): Condition = field(this).notIn(values.asList())




© 2015 - 2024 Weber Informatics LLC | Privacy Policy