ServiceResponseBuilder<T,E> Class
- java.
lang. Object - com.
microsoft. bot. restclient. ServiceResponseBuilder<T,E>
- com.
Type Parameters
- T
The return type the caller expects from the REST response.
- E
the exception to throw in case of error.
Implements
public final class ServiceResponseBuilder<T,E>
implements ResponseBuilder<T,E>
The builder for building a ServiceResponse<T>.
Method Summary
Modifier and Type | Method and Description |
---|---|
Service |
<THeader>buildEmptyWithHeaders(Response<Void> response, Class<THeader> headerType)
Build a Service |
Service |
<THeader>buildWithHeaders(Response<ResponseBody> response, Class<THeader> headerType)
Build a Service |
Service |
build(Response<ResponseBody> response)
Build a Service |
Service |
buildEmpty(Response<Void> response)
Build a Service |
java.lang.Class<> | exceptionType() |
boolean |
isSuccessful(int statusCode)
Check if the returned status code will be considered a success for this builder. |
Service |
register(int statusCode, Type type)
Register a mapping from a response status code to a response destination type. |
Service |
registerAll(Map<Integer,Type> responseTypes)
Register all the mappings from a response status code to a response destination type stored in a Map. |
Service |
registerError(Class<? extends RestException> type)
Register a destination type for errors with models. |
Service |
withThrowOnGet404(boolean throwOnGet404)
Specifies whether to throw on 404 responses from a GET call. |
Methods inherited from java.lang.Object
Method Details
<THeader>buildEmptyWithHeaders
public ServiceResponseWithHeaders
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.
If 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.
Parameters:
Throws:
<THeader>buildWithHeaders
public ServiceResponseWithHeaders
Build a ServiceResponseWithHeaders instance from a REST call response, a header in JSON format, and a possible error.
If 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.
Parameters:
Throws:
build
public ServiceResponse
Build a ServiceResponse instance from a REST call response and a possible error.
If 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.
Parameters:
Throws:
buildEmpty
public ServiceResponse
Build a ServiceResponse instance from a REST call response and a possible error, which does not have a response body.
If 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.
Parameters:
Throws:
exceptionType
public Class extends RestException> exceptionType()
Returns:
isSuccessful
public boolean isSuccessful(int statusCode)
Check if the returned status code will be considered a success for this builder.
Parameters:
Returns:
register
public ServiceResponseBuilder
Register a mapping from a response status code to a response destination type.
Parameters:
registerAll
public ServiceResponseBuilder
Register all the mappings from a response status code to a response destination type stored in a Map.
Parameters:
Returns:
registerError
public ServiceResponseBuilder
Register a destination type for errors with models.
Parameters:
withThrowOnGet404
public ServiceResponseBuilder
Specifies whether to throw on 404 responses from a GET call.
Parameters:
Returns: