Patrik Åkerfeldt
12/03/2020, 5:34 PMannotation class MyAnnotation(val someValue: String, val optionalClass: KClass<*> = MyDefaultImplementation::class)
interface MyInterface {
fun doSomething(input: Any?): Any?
}
class MyDefaultImplementation: MyInterface {
override fun doSomething(input: Any?): Any? = input.toString()
}
How can I set a bound on optionalClass
to make sure only a class which implements MyInterface
is provided?Edgars
12/03/2020, 5:37 PMval optionalClass: KClass<out MyInterface>
should work.Patrik Åkerfeldt
12/03/2020, 5:38 PM