[jOOQ/jOOQ#14006] Add ResultQuery<Record2<T1, T2>>.fetchMap() and fetchGroups() extension methods to jOOQ-kotlin
This commit is contained in:
parent
0eb91e9ff4
commit
2015e67ebf
@ -1,5 +1,6 @@
|
||||
package org.jooq.kotlin
|
||||
|
||||
import org.jetbrains.annotations.Blocking
|
||||
import org.jooq.*
|
||||
import org.jooq.impl.DSL.*
|
||||
import java.util.stream.Collector
|
||||
@ -38,6 +39,39 @@ fun <E, R : Record1<E>> Field<Result<R>>.intoSet(): Field<Set<E>> = collecting(R
|
||||
|
||||
fun <E, R : Record> Field<Result<R>>.intoSet(mapper: (R) -> E): Field<Set<E>> = collecting(Records.intoSet(mapper))
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Extensions to collect ResultQuery<Record[N]> into other types
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
@Blocking
|
||||
inline fun <reified E> ResultQuery<Record1<E>>.fetchArray(): Array<E> = collect(Records.intoArray(E::class.java))
|
||||
|
||||
@Blocking
|
||||
fun <K, V, R : Record2<K, V>> ResultQuery<R>.fetchGroups(): Map<K, List<V>> = collect(Records.intoGroups())
|
||||
|
||||
@Blocking
|
||||
fun <E, R : Record1<E>> ResultQuery<R>.fetchList(): List<E> = collect(Records.intoList())
|
||||
|
||||
@Blocking
|
||||
fun <K, V> ResultQuery<Record2<K, V>>.fetchMap(): Map<K, V> = collect(Records.intoMap())
|
||||
|
||||
@Blocking
|
||||
fun <E, R : Record1<E>> ResultQuery<R>.fetchSet(): Set<E> = collect(Records.intoSet())
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Extensions to collect Result<Record[N]> into other types
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
inline fun <reified E> Result<Record1<E>>.intoArray(): Array<E> = collect(Records.intoArray(E::class.java))
|
||||
|
||||
fun <K, V, R : Record2<K, V>> Result<R>.intoGroups(): Map<K, List<V>> = collect(Records.intoGroups())
|
||||
|
||||
fun <E, R : Record1<E>> Result<R>.intoList(): List<E> = collect(Records.intoList())
|
||||
|
||||
fun <K, V> Result<Record2<K, V>>.intoMap(): Map<K, V> = collect(Records.intoMap())
|
||||
|
||||
fun <E, R : Record1<E>> Result<R>.intoSet(): Set<E> = collect(Records.intoSet())
|
||||
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
Loading…
Reference in New Issue
Block a user