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
12
12
13
13
import kotlin.reflect.KProperty
14
14
15
- private object Lock
16
-
17
15
class NullableDelegate <T >(private val supplier : () -> T ? ) {
18
16
private var field: T ? = null
19
17
18
+ private val lock = Lock ()
19
+
20
20
operator fun getValue (thisRef : Any? , property : KProperty <* >): T ? {
21
21
if (field != null ) {
22
22
return field
23
23
}
24
24
25
- synchronized(Lock ) {
25
+ synchronized(lock ) {
26
26
if (field != null ) {
27
27
return field
28
28
}
@@ -36,6 +36,8 @@ class NullableDelegate<T>(private val supplier: () -> T?) {
36
36
operator fun setValue (thisRef : Any? , property : KProperty <* >, value : T ? ) {
37
37
this .field = value
38
38
}
39
+
40
+ private inner class Lock
39
41
}
40
42
41
43
fun <T > nullable (supplier : () -> T ? ): NullableDelegate <T > = NullableDelegate (supplier)
You can’t perform that action at this time.
0 commit comments