Reputation: 610
I have a Generic Interface for retrofit2 http request
interface BaseGetRequest<T: Any> {
@GET fun requestGet(@Url urlGetRequest: String,@FieldMap parameters: Map<String, String>): Single<T>
}
and now I need to pass the BaseGetRequest to retrofit2 as class reference, in java this is just treated as BaseGetRequest.java, but does not allow in kotlin because it says type mismatch.
How do I solve this?
Upvotes: 0
Views: 549
Reputation: 6612
Basically you should return type that you want to get as response.
If you do not need result I would recommend to use Completable
instead of Single
.
But if you need single guess you can write just:
NetworkUtils.builder().create(BaseRequest::class.java)
without any diamond operator
Upvotes: 1