kirillrakhman

    kirillrakhman

    5 years ago
    abstract class KnowsChildrenTypes() {
        companion object {
            val types = mutableSetOf<Class<out KnowsChildrenTypes>>()
        }
        
        init {
            types += this::class.java
        }
    }
    
    class Child1 : KnowsChildrenTypes()
    class Child2 : KnowsChildrenTypes()
    snowe

    snowe

    5 years ago
    @levans002 oops linked to wrong item. did you try something like this?
    kirillrakhman

    kirillrakhman

    5 years ago
    no, just came up with it
    snowe

    snowe

    5 years ago
    @kirillrakhman sorry, i was tagging my coworker so he would see this solution. Apparently this won't work for him because he needs to know what classes he can init before they are ever instantiated.
    kirillrakhman

    kirillrakhman

    5 years ago
    then you'll need a classpath scan