jvmMain.com.bkahlert.kommons.JvmReflections.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kommons-core-jvm Show documentation
Show all versions of kommons-core-jvm Show documentation
Kommons Core is a Kotlin Multiplatform Library that offers shared features for all Kommons modules.
package com.bkahlert.kommons
import kotlin.reflect.KClass
/** The list of all subclasses if this class is a sealed class, or an empty list otherwise. */
public val KClass.allSealedSubclasses: List>
get() = buildList {
sealedSubclasses.forEach { sealedSubclass ->
add(sealedSubclass)
addAll(sealedSubclass.allSealedSubclasses)
}
}
/** The list of all subclasses that are singletons if this class is a sealed class, or an empty list otherwise. */
public val KClass.allSealedObjectInstances: List
get() = allSealedSubclasses.mapNotNull { it.objectInstance }
© 2015 - 2025 Weber Informatics LLC | Privacy Policy