All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jvmMain.com.bkahlert.kommons.JvmReflections.kt Maven / Gradle / Ivy

Go to download

Kommons Core is a Kotlin Multiplatform Library that offers shared features for all Kommons modules.

There is a newer version: 2.8.0
Show newest version
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