inline fun <reified T: Any>notNullProperties(data: T, callBack :(list: List<String>)->Unit){
val allNullData = mutableListOf<String>()
for (prop in T::class.memberProperties) {
if ( prop.get(data) == null){
allNullData.add(prop.name)
}
}
callBack.invoke(allNullData)
}
- Use case
val changePassword = ChangePassword()
notNullProperties(changePassword){
if (it.isEmpty()){
println("not null")
}else{
println("Null : $it")
}
}
0 comments:
Post a Comment