Created
September 30, 2018 21:36
-
-
Save adam-arold/2bf26217a968a4d9366b44f8d643868a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class NotNullVar<T : Any> : ReadWriteProperty<Any?, T> { | |
private var value: T? = null | |
public override fun getValue(thisRef: Any?, property: KProperty<*>): T { | |
return value ?: throw IllegalStateException("Property ${property.name} should be initialized before get.") | |
} | |
public override fun setValue(thisRef: Any?, property: KProperty<*>, value: T) { | |
this.value = value | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment