bloodshura
02/12/2017, 2:30 AMfun DtoStructure.validateAllLateinit(): Boolean {
for (method in javaClass.methods) {
if (method.name.startsWith("get")) {
try {
method(this)
}
catch (exception: InvocationTargetException) {
if (exception.cause is UninitializedPropertyAccessException) {
return false
}
}
}
}
return true
}
... which feels weird to me. I just got "lucky" that Kotlin fields are converted into getter/setters when compiled to bytecode, and I'm using this fact as a workaround.
Anyone knows something better? Maybe using the Reflection API of Kotlin, and not Java?