Jonathan Mew
10/11/2021, 4:29 PM@Suppress("UNCHECKED_CAST")
fun <IdType> createWidgetFactory(cls: KClass<out IdType>): WidgetFactory<IdType> =
when (cls) {
IdA::class -> WidgetFactoryA() as WidgetFactory<IdType>
IdB::class -> WidgetFactoryB() as WidgetFactory<IdType>
else -> throw UnsupportedOperationException("Unknown WidgetFactory type!")
}
Jakob
10/11/2021, 8:10 PMTomasz Krakowiak
10/11/2021, 8:32 PMJonathan Mew
10/13/2021, 8:30 AMis
check here.