df
08/23/2020, 9:14 PMdf
08/23/2020, 9:25 PMfun <T : Any> map(data : SomeData, type: KClass<T>) : Foo<T> = objectMapper.readValue(objectMapper.writeValueAsString(data), my-instance-of-kclass<Foo<type>>)
and then the method would be called with map(data, Bar::class)
. And of course I could use reified/inline function and then the second argument to readValue would be Foo<T>
but I want the non-reified version of it 😉Zach Klippenstein (he/him) [MOD]
08/24/2020, 2:49 AMKClass<Foo<Bar>>
and KClass<Bar>
are completely different values - KClass<Foo<Bar>>
is really just KClass<Foo<*>>
. KCLasses don't know about type arguments at all, since they are erased at runtime. KType
is, but needs the full kotlin reflection library for most functionality.df
08/24/2020, 7:07 AMFoo<Bar>
to the method instead of just Bar
Zach Klippenstein (he/him) [MOD]
08/24/2020, 2:40 PMdf
08/24/2020, 5:55 PMMap<String, Any?>
from the sdk. Then I'm trying to remap it to a more specific (strongly typed properties) dto. But I'm pretty sure I got something wrong in my head. Thanks anyway ;)