【发布时间】:2020-11-15 09:58:27
【问题描述】:
通过okhttp3.Request#tag(Invocation::class.java),我们可以得到methodName,annotations等。有没有什么方法可以使用Invocation类获取方法的返回类型。
我试过了
request.tag(Invocation::class.java)!!.method().returnTyperequest.tag(Invocation::class.java)!!.method().genericReturnType
但他们都只是返回class java.lang.Object,即使它是List。
预期输出
@GET("products")
suspend fun getProducts(): List<Product> // I need to get at least `List` as a String for this method
@GET("product")
suspend fun getProduct(): Product // I need to get at least `Object` as a String for this method
【问题讨论】:
标签: java android kotlin retrofit okhttp