I want to find all object derived from a certain class (Config
), what is easy to do with the Reflections library:
interface Config {
val name: String
}
object MyConfig : Config {
override val name = "demo"
}
val reflections = Reflections("org.demo")
val configClass = reflections.getSubTypesOf(Config::class.java).first()
I get the class as expected. But how do I get the singleton object MyConfig
for this class? I don’t want to create a new instance, but get the existing one.