File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed
src/main/kotlin/com/demonwav/mcdev/util Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -12,17 +12,17 @@ package com.demonwav.mcdev.util
1212
1313import kotlin.reflect.KProperty
1414
15- private object Lock
16-
1715class NullableDelegate <T >(private val supplier : () -> T ? ) {
1816 private var field: T ? = null
1917
18+ private val lock = Lock ()
19+
2020 operator fun getValue (thisRef : Any? , property : KProperty <* >): T ? {
2121 if (field != null ) {
2222 return field
2323 }
2424
25- synchronized(Lock ) {
25+ synchronized(lock ) {
2626 if (field != null ) {
2727 return field
2828 }
@@ -36,6 +36,8 @@ class NullableDelegate<T>(private val supplier: () -> T?) {
3636 operator fun setValue (thisRef : Any? , property : KProperty <* >, value : T ? ) {
3737 this .field = value
3838 }
39+
40+ private inner class Lock
3941}
4042
4143fun <T > nullable (supplier : () -> T ? ): NullableDelegate <T > = NullableDelegate (supplier)
You can’t perform that action at this time.
0 commit comments