somoni
03/27/2017, 2:56 PMinternal object model {
val layer = object {
val zOrder: Int = 0
val lList = HashSet<String>()
}
}
fun main(args: Array<String>) {
checkProperty(model.layer::class)
}
fun checkProperty(kClass: KClass<*>) {
val properties = kClass.java.kotlin.memberProperties
properties.forEach { kProperty ->
val pClass = kProperty.returnType.classifier
if (pClass == Int::class) { //works for the int
println("name:${kProperty.name} type:Int")
} else if (pClass is ParameterizedType) { // does not work !
println("name:${kProperty.name} type:ParameterizedType")
} else if (pClass is HashSet<*>) { // does not work !
println("name:${kProperty.name} type:HashSet<*>")
} else if (pClass == HashSet::class) { // works !
println("name:${kProperty.name} type:HashSet::class")
}
}
}
^^^^ How do you check for the parametrised type that was used for lList ? I just need the expression that was used to construct that object ?