Andrew Gazelka
02/13/2019, 2:28 PMAny) is such that Kotlin can not recognize it as a delegate. Any way I can fix this?
inline fun <reified T : Any> ConfigurationSection.tester(
basePath: String,
default: T,
crossinline accept: (T) -> Boolean = { true }
): Any {
return object {
operator fun getValue(thisRef: T, property: KProperty<*>): T {
val camelCase = property.name.hyphenate()
val path = "$basePath.$camelCase"
val res = this@tester[path]
return when (res) {
null, !is T, !accept(res) -> {
this@tester[path] = default
default
}
else -> res
}
}
}
}