I feel like I’ve seen code like this written ``` ...
# announcements
x
I feel like I’ve seen code like this written
Copy code
deserialize<PatientDto>(message.payload)
where the called method then gets the class
Copy code
internal fun <DTO : Any> deserialize( ba: ByteArray, clazz: KClass<DTO> ): DTO {
        return mapper.readValue(ba, clazz.java)
    }
pretty sure it’s in gradle’s kotlin DSL somewhere… how do I replicate that calling signature?
c
p
Something like this:
Copy code
inline fun <reified T> foo() {
    foo(T::class)
}

fun <T> foo(clazz: KClass<T>) {
    
}
x
does it have to be only that as a parameter?
Copy code
internal inline fun <reified DTO : Any> deserialize(ba: ByteArray, clazz: Class<DTO> ): DTO {
        return mapper.readValue(ba, clazz)
    }
isn’t showing me any love
the caller says the parameter is missing
c
you've added an unnecessary param to the signature. Should be:
Copy code
internal inline fun <reified DTO : Any> deserialize(ba: ByteArray): DTO {
    return mapper.readValue(ba, DTO::class.java)
}
💯 3