singleSetReference
fun <T> singleSetReference(initValue: T? = null, compareValue: T? = initValue): ReadWriteProperty<Any?, T?>
Creates a thread-safe delegate that can only be set once.
The property starts at initValue. The first assignment, including an assignment of null, sets it; any later assignment throws IllegalStateException.
Return
a ReadWriteProperty delegate
Parameters
initValue
optional initial value (default null)
compareValue
the value the property holds before its one assignment; defaults to initValue and must equal it (compared with ==)
Type Parameters
T
the property type
Throws
if compareValue is not equal to initValue