public final class Java8CallAdapterFactory extends CallAdapter.Factory
Adding this class to Retrofit allows you to return CompletableFuture from
service methods.
interface MyService {
@GET("user/me")
CompletableFuture<User> getUser()
}
There are two configurations supported for the CompletableFuture type parameter:
CompletableFuture<User>) returns the deserialized body for 2XX
responses, sets HttpException errors for non-2XX responses, and
sets IOException for network errors.CompletableFuture<Response<User>>) returns a
Response object for all HTTP responses and sets IOException for network
errors| Modifier and Type | Method and Description |
|---|---|
static Java8CallAdapterFactory |
create() |
CallAdapter<?,?> |
get(Type returnType,
Annotation[] annotations,
Retrofit retrofit)
Returns a call adapter for interface methods that return
returnType, or null if it
cannot be handled by this factory. |
getParameterUpperBound, getRawTypepublic static Java8CallAdapterFactory create()
public CallAdapter<?,?> get(Type returnType, Annotation[] annotations, Retrofit retrofit)
CallAdapter.FactoryreturnType, or null if it
cannot be handled by this factory.get in class CallAdapter.FactoryCopyright © 2017 Square, Inc.. All rights reserved.