Reputation: 871
I retrieved a property of my class using:
val prop = businessObject::class.memberProperties.first()
I can do this:
prop.javaGetter
But this method does not compile:
prop.javaSetter
Even though the method exists and is not deprecated
Upvotes: 0
Views: 64
Reputation: 692121
It's not compiling because memberProperties
is a Collection<KProperty1>
, and KProperty1
doesn't have any javaSetter
property. But you can test if the property is in fact a KMutableProperty1
, and if it is, after a cast or a smart cast, use its javaSetter
property.
As you can see, the documentation helps. Use it.
Upvotes: 4