Version 1.1.3
- Add check on references
This commit is contained in:
2
.idea/kotlinc.xml
generated
2
.idea/kotlinc.xml
generated
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="KotlinJpsPluginSettings">
|
<component name="KotlinJpsPluginSettings">
|
||||||
<option name="version" value="2.0.0" />
|
<option name="version" value="2.0.21" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
@@ -1,14 +1,14 @@
|
|||||||
import org.gradle.model.internal.core.ModelNodes.withType
|
import org.gradle.model.internal.core.ModelNodes.withType
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
kotlin("jvm") version "2.0.21"
|
kotlin("jvm") version "2.1.0"
|
||||||
`maven-publish`
|
`maven-publish`
|
||||||
signing
|
signing
|
||||||
id("org.jetbrains.dokka") version "1.5.31"
|
id("org.jetbrains.dokka") version "1.5.31"
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "nl.astraeus"
|
group = "nl.astraeus"
|
||||||
version = "1.1.3-SNAPSHOT"
|
version = "1.1.3"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
|||||||
@@ -20,10 +20,16 @@ class Reference<S : Persistable>(
|
|||||||
var id: Long = initialValue.id
|
var id: Long = initialValue.id
|
||||||
|
|
||||||
operator fun getValue(thisRef: Persistable, property: KProperty<*>): S {
|
operator fun getValue(thisRef: Persistable, property: KProperty<*>): S {
|
||||||
|
check(currentTransaction() != null) {
|
||||||
|
"No transaction available"
|
||||||
|
}
|
||||||
return currentTransaction()?.find(cls.kotlin, id) ?: throw IllegalStateException("Reference not found")
|
return currentTransaction()?.find(cls.kotlin, id) ?: throw IllegalStateException("Reference not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
operator fun setValue(thisRef: Persistable, property: KProperty<*>, value: S) {
|
operator fun setValue(thisRef: Persistable, property: KProperty<*>, value: S) {
|
||||||
|
check(currentTransaction() != null) {
|
||||||
|
"No transaction available"
|
||||||
|
}
|
||||||
currentTransaction()?.store(value)
|
currentTransaction()?.store(value)
|
||||||
id = value.id
|
id = value.id
|
||||||
}
|
}
|
||||||
@@ -40,10 +46,16 @@ class NullableReference<S : Persistable>(
|
|||||||
var id: Long? = initialValue?.id
|
var id: Long? = initialValue?.id
|
||||||
|
|
||||||
operator fun getValue(thisRef: Persistable, property: KProperty<*>): S? {
|
operator fun getValue(thisRef: Persistable, property: KProperty<*>): S? {
|
||||||
|
check(currentTransaction() != null) {
|
||||||
|
"No transaction available"
|
||||||
|
}
|
||||||
return currentTransaction()?.find(cls.kotlin, id ?: 0L)
|
return currentTransaction()?.find(cls.kotlin, id ?: 0L)
|
||||||
}
|
}
|
||||||
|
|
||||||
operator fun setValue(thisRef: Persistable, property: KProperty<*>, value: S?) {
|
operator fun setValue(thisRef: Persistable, property: KProperty<*>, value: S?) {
|
||||||
|
check(currentTransaction() != null) {
|
||||||
|
"No transaction available"
|
||||||
|
}
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
// todo: only store if not already stored?
|
// todo: only store if not already stored?
|
||||||
currentTransaction()?.store(value)
|
currentTransaction()?.store(value)
|
||||||
|
|||||||
Reference in New Issue
Block a user