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

org.babyfish.jimmer.sql.kt.Mutations.kt Maven / Gradle / Ivy

There is a newer version: 0.9.35
Show newest version
package org.babyfish.jimmer.sql.kt

import org.babyfish.jimmer.kt.toImmutableProp
import org.babyfish.jimmer.sql.ast.mutation.AbstractMutationResult
import org.babyfish.jimmer.sql.runtime.MutationPath
import org.babyfish.jimmer.sql.exception.SaveException
import kotlin.reflect.KClass
import kotlin.reflect.KProperty1

fun MutationPath.contains(type: KClass<*>): Boolean =
    contains(type.java)

fun MutationPath.contains(prop: KProperty1<*, *>): Boolean =
    contains(prop.toImmutableProp())

fun AbstractMutationResult.getAffectedRowCount(type: KClass<*>): Int =
    getAffectedRowCount(type.java)

fun AbstractMutationResult.getAffectedRowCount(prop: KProperty1<*, *>): Int =
    getAffectedRowCount(prop.toImmutableProp())

fun  SaveException.NotUnique.isMatched(
    vararg props: KProperty1
): Boolean = isMatched(
    *props.map { it.toImmutableProp() }.toTypedArray()
)

@Suppress("UNCHECKED_CAST")
operator fun  SaveException.NotUnique.get(prop: KProperty1<*, T>): T =
    getValue(prop.toImmutableProp()) as T




© 2015 - 2024 Weber Informatics LLC | Privacy Policy