Package ratpack.retrofit
Class RatpackRetrofit.Builder
- java.lang.Object
-
- ratpack.retrofit.RatpackRetrofit.Builder
-
- Enclosing class:
- RatpackRetrofit
public static class RatpackRetrofit.Builder extends Object
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> T
build(Class<T> service)
Uses this builder to create a Retrofit client implementation.RatpackRetrofit.Builder
configure(Action<? super Retrofit.Builder> builderAction)
Configure the underlyingRetrofit.Builder
instance.RatpackRetrofit.Builder
httpClient(Factory<? extends HttpClient> clientFactory)
Configures aFactory
that supplies the underlyingHttpClient
to back client interfaces generated from the return ofretrofit()
Retrofit
retrofit()
Creates the underlyingRetrofit
instance and configures it to interface withHttpClient
andPromise
.
-
-
-
Method Detail
-
configure
public RatpackRetrofit.Builder configure(Action<? super Retrofit.Builder> builderAction)
Configure the underlyingRetrofit.Builder
instance.This is used to customize the behavior of Retrofit.
- Parameters:
builderAction
- the actions to apply to the Retrofit builder- Returns:
this
- See Also:
Converter.Factory
,CallAdapter.Factory
-
httpClient
public RatpackRetrofit.Builder httpClient(Factory<? extends HttpClient> clientFactory)
Configures aFactory
that supplies the underlyingHttpClient
to back client interfaces generated from the return ofretrofit()
By default, the following locations are searched in order, with the first
HttpClient
found used to back the client interfaces.If no
HttpClient
is found, aNotInRegistryException
is thrown.- Parameters:
clientFactory
- a factory that generates a HttpClient to be used- Returns:
this
- Since:
- 1.6
-
retrofit
public Retrofit retrofit()
Creates the underlyingRetrofit
instance and configures it to interface withHttpClient
andPromise
.The resulting Retrofit instance can be re-used to generate multiple client interfaces which share the same base URI.
- Returns:
- the Retrofit instance to create client interfaces
-
build
public <T> T build(Class<T> service)
Uses this builder to create a Retrofit client implementation.This is the short form of calling
builder.retrofit().create(service)
.- Type Parameters:
T
- the type of the client interface.- Parameters:
service
- the client interface to generate.- Returns:
- a generated instance of the client interface.
-
-