Daniel Felipe Henao Toro
02/21/2023, 2:03 PMreturn exchangeWithRetry(
budgetSplitterUrl,
HttpMethod.PUT,
budgetSplitter,
XandrFlatResponse<XandrBudgetSplitter>()::class
).splits ?: emptyList()
fun <T> exchangeWithRetry(
uri: String,
method: HttpMethod,
body: Any,
responseClass: KClass<T>
) {
//Here how can I know KClass of this class XandrBudgetSplitter from this complete XandrFlatResponse<XandrBudgetSplitter>()::class
}
If anyone knows how to do that, I really appreciate it. ThanksJoffrey
02/21/2023, 2:19 PMKClass
for XandrFlatResponse<XandrBudgetSplitter>
, because that expression is more general type, not just a class. Actually, XandrFlatResponse<XandrBudgetSplitter>()::class
is a very strange way to get a class, and it already is just XandrFlatResponse
, as if you had specified just XandrFlatResponse::class
. The correct type to access the full type information would be KType
Daniel Felipe Henao Toro
02/21/2023, 2:23 PMJoffrey
02/21/2023, 2:24 PMreturn exchangeWithRetry(
budgetSplitterUrl,
HttpMethod.PUT,
budgetSplitter,
typeOf<XandrFlatResponse<XandrBudgetSplitter>>,
).splits ?: emptyList()
fun <T> exchangeWithRetry(
uri: String,
method: HttpMethod,
body: Any,
responseType: KType,
) {
val typeArg = responseType.arguments[0].type
// ...
}
Daniel Felipe Henao Toro
02/21/2023, 2:25 PM