我试图创建一个进度条,检查用户是否已将数据填充到数据库中。
到目前为止,我已经做到了,但是有没有更短的方法呢?此外,我在MYSQL工作台上收到一条警告消息,说
“选择对于此服务器版本在此位置无效,期望:'(',
SELECT * FROM userCertificate
WHERE certificatename IS NOT NULL
AND organization IS NOT NULL
AND location IS NOT NULL
AND startdate IS NOT NULL;
答案 0 :(得分:0)
您可以将COALESCE函数用于多列
class User : MyType {
val address: Address? = null
val company: Company? = null
...
}
class Address : MyType {
val city: String? = null
}
class Company : MyType {
val name: String? = null
}
var properties: MutableMap<String, Collection<KProperty1<Any, *>>>? = mutableMapOf()
fun init() {
fillPropertiesMap(User::class.java)
}
private inline fun <reified T : Any> fillPropertiesMap(clazz: Class<T>) {
val prop = clazz.kotlin.memberProperties
.filter { it.visibility == KVisibility.PUBLIC } as Collection<KProperty1<Any, *>>
fill(clazz as Class<Any>, prop)
}
fun fill(clazz: Class<Any>, props: Collection<KProperty1<Any, *>>) {
properties[clazz.simpleName] = props
props.forEach()
{ prop ->
if (isMyCustomType(prop)) {
fillPropertiesMap(prop.????) . // how get class from KProperty1 for Address.class and Company.class
}
}
}