Skip to content

Instantly share code, notes, and snippets.

View sugihaya's full-sized avatar
🦖

はやとん sugihaya

🦖
View GitHub Profile
@sugihaya
sugihaya / sample.kt
Created December 12, 2023 04:02
リフレションを使った自作assert
fun assertAllPropertiesNotNull(obj: Any) {
obj::class.memberProperties
.forEach { p ->
val value = (p as KProperty1<Any?, *>).get(obj) ?: throw AssertionFailedError("${p.name} is null", null, null)
assertNotNull(value, "${p.name} is null")
if (value.isUncheckType()) {
return@forEach // continue
}