From 30fb67f63a2b5b0f0c71cf4b9258b3804f7acc4a Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 30 Mar 2025 16:32:04 +0700 Subject: [PATCH] Remove NotNullVar lateinit should be used instead, really --- .../ru/dbotthepony/mc/otm/util/NotNullVar.kt | 32 ------------------- 1 file changed, 32 deletions(-) delete mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/util/NotNullVar.kt diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/util/NotNullVar.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/util/NotNullVar.kt deleted file mode 100644 index 2166b1c51..000000000 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/util/NotNullVar.kt +++ /dev/null @@ -1,32 +0,0 @@ -package ru.dbotthepony.mc.otm.util - -import ru.dbotthepony.kommons.util.Delegate -import ru.dbotthepony.kommons.util.KOptional -import kotlin.properties.Delegates -import kotlin.properties.ReadWriteProperty -import kotlin.reflect.KProperty - -/** - * Different from [Delegates.notNull] by allowing [V] to be nullable - */ -class NotNullVar : Delegate, ReadWriteProperty { - private var value: KOptional = KOptional() - - override fun accept(t: V) { - value = KOptional(t) - } - - override fun get(): V { - value.ifPresent { return it } - throw IllegalStateException("Uninitialized variable") - } - - override fun getValue(thisRef: Any?, property: KProperty<*>): V { - value.ifPresent { return it } - throw IllegalStateException("Uninitialized variable ${property.name}") - } - - override fun setValue(thisRef: Any?, property: KProperty<*>, value: V) { - accept(value) - } -}