mardi 14 janvier 2020

Kotlin reflection: get instance of a member property

I'm trying to retrieve the instances of my properties, like the example below:

data class DataClass(
    val inner: InnerClass
)

data class AnotherDataClass(
    val annotatedProperty: String,
    val dataClass: DataClass
)


instance = AnotherDataClass("prop", DataClass("anotherprop"))

instance::class.memberProperties.forEach {
    // how to retrieve the instance of the properties here?
}




Aucun commentaire:

Enregistrer un commentaire