mercredi 20 septembre 2017

How do I get a KProperty1 from a KProperty0

In my API I have overridden invoke on KProperty0 to do certain actions and I provide an instance to get these properties:

api {
    instance::property1 { /* Do stuff */ }
}

But instead of the KProperty0 I need the corresponding KProperty1. Currently I search the property of the class with the same name as the KProperty0.

operator fun KProperty0<*>.invoke(...) {
    val kproperty1 = T::class.memberProperties.find { it.name == this.name }
}

Is there a way to get the KProperty1 without iterating over all of them?





Aucun commentaire:

Enregistrer un commentaire