I know that you cannot use delegated property syntax in Java and do not get the convenience of "overriding" the set / get statements, as in Kotlin, but I would still like to use the existing property delegate in Java.
For example, a simple int delegate:
class IntDelegate { operator fun getValue(thisRef: Any?, property: KProperty<*>) = 0 }
In Kotlin, of course, we can use it like this:
val x by IntDelegate()
But how can we use IntDelegate in some form in Java? This is the beginning, I believe:
final IntDelegate x = new IntDelegate();
And then using the functions directly. But how can I use the getValue function? What should I pass for its parameters? How to get KProperty field for Java?
source share