lundi 17 février 2020

How do I get a reflection on a property's property in Kotlin?

say we have a class with a property subClass.

class TestClass(val property: SubClass)

The SubClass has its own property

class SubClass(val subProperty: Any?)

When I only have access to the class itself, I know that I can easily get a reflection to the property via

val reflection = TestClass::property

However, how do I get access to the subProperty via reflection? The following does not work:

val subReflection = TestClass::property::subProperty

I'd apprectiate any insight on that! Thanks!





Aucun commentaire:

Enregistrer un commentaire