mardi 14 janvier 2020

Kotlin: Check if a KTypeProperty1 is a data class

Using reflection I can iterate through my attributes:

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


AnotherDataClass::class.memberProperties.filter {
    return it::class.isData
}

But it::class.isData is always false since the type of it is jvm.internal.KProperty1Impl. Is there a way to check if this class is a data class?





Aucun commentaire:

Enregistrer un commentaire