| Constructor and Description |
|---|
Builder() |
| Modifier and Type | Method and Description |
|---|---|
Retrofit.Builder |
addCallAdapterFactory(CallAdapter.Factory factory)
Add a call adapter factory for supporting service method return types other than
Call. |
Retrofit.Builder |
addConverterFactory(Converter.Factory factory)
Add converter factory for serialization and deserialization of objects.
|
Retrofit.Builder |
baseUrl(BaseUrl baseUrl)
Set an API base URL which can change over time.
|
Retrofit.Builder |
baseUrl(okhttp3.HttpUrl baseUrl)
Set a fixed API base URL.
|
Retrofit.Builder |
baseUrl(String baseUrl)
Set a fixed API base URL.
|
Retrofit |
build()
Create the
Retrofit instance using the configured values. |
Retrofit.Builder |
callbackExecutor(Executor executor)
|
Retrofit.Builder |
callFactory(okhttp3.Call.Factory factory)
Specify a custom call factory for creating
Call instances. |
Retrofit.Builder |
client(okhttp3.OkHttpClient client)
The HTTP client used for requests.
|
Retrofit.Builder |
validateEagerly(boolean validateEagerly)
When calling
Retrofit.create(java.lang.Class<T>) on the resulting Retrofit instance, eagerly validate
the configuration of all methods in the supplied interface. |
public Retrofit.Builder client(okhttp3.OkHttpClient client)
This is a convenience method for calling callFactory.
Note: This method does not make a defensive copy of client. Changes to its
settings will affect subsequent requests. Pass in a cloned
instance to prevent this if desired.
public Retrofit.Builder callFactory(okhttp3.Call.Factory factory)
Call instances.
Note: Calling client(okhttp3.OkHttpClient) automatically sets this value.
public Retrofit.Builder baseUrl(String baseUrl)
baseUrl(HttpUrl)public Retrofit.Builder baseUrl(okhttp3.HttpUrl baseUrl)
The specified endpoint values (such as with @GET) are resolved against this
value using HttpUrl.resolve(String). The behavior of this matches that of an
<a href=""> link on a website resolving on the current URL.
Base URLs should always end in /.
A trailing / ensures that endpoints values which are relative paths will correctly
append themselves to a base which has path components.
Correct:
Base URL: http://example.com/api/
Endpoint: foo/bar/
Result: http://example.com/api/foo/bar/
Incorrect:
Base URL: http://example.com/api
Endpoint: foo/bar/
Result: http://example.com/foo/bar/
This method enforces that baseUrl has a trailing /.
Endpoint values which contain a leading / are absolute.
Absolute values retain only the host from baseUrl and ignore any specified path
components.
Base URL: http://example.com/api/
Endpoint: /foo/bar/
Result: http://example.com/foo/bar/
Base URL: http://example.com/
Endpoint: /foo/bar/
Result: http://example.com/foo/bar/
Endpoint values may be a full URL.
Values which have a host replace the host of baseUrl and values also with a scheme
replace the scheme of baseUrl.
Base URL: http://example.com/
Endpoint: https://github.com/square/retrofit/
Result: https://github.com/square/retrofit/
Base URL: http://example.com
Endpoint: //github.com/square/retrofit/
Result: http://github.com/square/retrofit/ (note the scheme stays 'http')
public Retrofit.Builder baseUrl(BaseUrl baseUrl)
baseUrl(HttpUrl)public Retrofit.Builder addConverterFactory(Converter.Factory factory)
public Retrofit.Builder addCallAdapterFactory(CallAdapter.Factory factory)
Call.public Retrofit.Builder callbackExecutor(Executor executor)
Callback methods are invoked when returning Call from
your service method.
Note: executor is not used for custom method
return types.
public Retrofit.Builder validateEagerly(boolean validateEagerly)
Retrofit.create(java.lang.Class<T>) on the resulting Retrofit instance, eagerly validate
the configuration of all methods in the supplied interface.public Retrofit build()
Retrofit instance using the configured values.
Note: If neither client(okhttp3.OkHttpClient) nor callFactory is called a default OkHttpClient will be created and used.
Copyright © 2016 Square, Inc.. All rights reserved.