L
L
Lordao2018-09-27 15:49:08
Android
Lordao, 2018-09-27 15:49:08

How to return a specific object from a method?

In one of the classes, a method of another class RequestInterface is called

val requestInterface = RequestInterface.getRetrofitBuild(ExampleApi::class.java)

In which the getRetrofitBuild method is located, returning the required object.
fun getRetrofitBuild(exampleApi : ExempleApi): ExampleApi {
            return Retrofit.Builder()
                    .baseUrl(baseDomain)
                    .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                    .addConverterFactory(GsonConverterFactory.create())
                    .build().create(exampleApi::class)
}

How can I make it so that in this method it was possible to override not only ExampleApi , but also other objects, for example, SimpleApi ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
illuzor, 2018-09-27
@iLLuzor

Use generics

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question