
com.lightningkite.lightningdb.KPropertyExtensions.kt Maven / Gradle / Ivy
package com.lightningkite.lightningdb
import com.lightningkite.khrysalis.SharedCode
import kotlin.reflect.KProperty1
private val KProperty1_setCopyImplementation = HashMap, (Any?, Any?)->Any?>()
fun KProperty1.setCopyImplementation(impl: (original: T, value: V) -> T) {
@Suppress("UNCHECKED_CAST")
KProperty1_setCopyImplementation[this] = impl as (Any?, Any?)->Any?
}
fun KProperty1.setCopy(original: T, value: V): T {
@Suppress("UNCHECKED_CAST")
val impl = KProperty1_setCopyImplementation[this] ?: throw Error("setCopy implementation not present for $this. Did you forget to call prepareModels()?")
return impl(original, value) as T
}
val DataClassPathPartial.compare: Comparator get() = compareBy { this.getAny(it) as? Comparable<*> }
© 2015 - 2025 Weber Informatics LLC | Privacy Policy