T - the return type from caller.E - the exception to throw in case of error.public final class AzureResponseBuilder<T,E extends RestException> extends Object implements ResponseBuilder<T,E>
ServiceResponse customized for Azure.| Modifier and Type | Class and Description |
|---|---|
static class |
AzureResponseBuilder.Factory
A factory to create an Azure response builder.
|
| Modifier and Type | Method and Description |
|---|---|
ServiceResponse<T> |
build(retrofit2.Response<okhttp3.ResponseBody> response)
Build a ServiceResponse instance from a REST call response and a
possible error.
|
ServiceResponse<T> |
buildEmpty(retrofit2.Response<Void> response)
Build a ServiceResponse instance from a REST call response and a
possible error, which does not have a response body.
|
<THeader> ServiceResponseWithHeaders<T,THeader> |
buildEmptyWithHeaders(retrofit2.Response<Void> response,
Class<THeader> headerType)
Build a ServiceResponseWithHeaders instance from a REST call response, a header
in JSON format, and a possible error, which does not have a response body.
|
<THeader> ServiceResponseWithHeaders<T,THeader> |
buildWithHeaders(retrofit2.Response<okhttp3.ResponseBody> response,
Class<THeader> headerType)
Build a ServiceResponseWithHeaders instance from a REST call response, a header
in JSON format, and a possible error.
|
ResponseBuilder<T,E> |
register(int statusCode,
Type type)
Register a mapping from a response status code to a response destination type.
|
ResponseBuilder<T,E> |
registerError(Class<? extends RestException> type)
Register a destination type for errors with models.
|
AzureResponseBuilder<T,E> |
withThrowOnGet404(boolean throwOnGet404)
Specifies whether to throw on 404 responses from a GET call.
|
public ResponseBuilder<T,E> register(int statusCode, Type type)
ResponseBuilderregister in interface ResponseBuilder<T,E extends RestException>statusCode - the status code.type - the type to deserialize.public ResponseBuilder<T,E> registerError(Class<? extends RestException> type)
ResponseBuilderregisterError in interface ResponseBuilder<T,E extends RestException>type - the type to deserialize.public ServiceResponse<T> build(retrofit2.Response<okhttp3.ResponseBody> response) throws IOException
ResponseBuilderIf the status code in the response is registered, the response will be considered valid and deserialized into the specified destination type. If the status code is not registered, the response will be considered invalid and deserialized into the specified error type if there is one. An AutoRestException is also thrown.
build in interface ResponseBuilder<T,E extends RestException>response - the Response instance from REST callTIOException - exceptions from deserializationpublic ServiceResponse<T> buildEmpty(retrofit2.Response<Void> response) throws E extends RestException, IOException
ResponseBuilderIf the status code in the response is registered, the response will be considered valid. If the status code is not registered, the response will be considered invalid. An AutoRestException is also thrown.
buildEmpty in interface ResponseBuilder<T,E extends RestException>response - the Response instance from REST callTE - exceptions from the REST callIOException - exceptions from deserializationE extends RestExceptionpublic <THeader> ServiceResponseWithHeaders<T,THeader> buildWithHeaders(retrofit2.Response<okhttp3.ResponseBody> response, Class<THeader> headerType) throws IOException
ResponseBuilderIf the status code in the response is registered, the response will be considered valid and deserialized into the specified destination type. If the status code is not registered, the response will be considered invalid and deserialized into the specified error type if there is one. An AutoRestException is also thrown.
buildWithHeaders in interface ResponseBuilder<T,E extends RestException>THeader - the type of the headerresponse - the Response instance from REST callheaderType - the type of the headerTIOException - exceptions from deserializationpublic <THeader> ServiceResponseWithHeaders<T,THeader> buildEmptyWithHeaders(retrofit2.Response<Void> response, Class<THeader> headerType) throws IOException
ResponseBuilderIf the status code in the response is registered, the response will be considered valid. If the status code is not registered, the response will be considered invalid. An AutoRestException is also thrown.
buildEmptyWithHeaders in interface ResponseBuilder<T,E extends RestException>THeader - the type of the headerresponse - the Response instance from REST callheaderType - the type of the headerTIOException - exceptions from deserializationpublic AzureResponseBuilder<T,E> withThrowOnGet404(boolean throwOnGet404)
throwOnGet404 - true if to throw; false to simply return null. Default is false.Copyright © 2019. All rights reserved.