T
- the type which is returned in a successful http request.public interface SphereRequest<T>
Typical workflow: A client executes httpRequestIntent()
and creates a future of an http response. When the future redeems the client uses the http response and passes it as
argument to canDeserialize(HttpResponse)
. If the call results in true, the client applies deserialize(HttpResponse)
to transform the http response into T.
Modifier and Type | Method and Description |
---|---|
default boolean |
canDeserialize(HttpResponse httpResponse)
Checks if the response can be handled by
deserialize(HttpResponse) . |
T |
deserialize(HttpResponse httpResponse)
Takes an http response and maps it into a Java object of type T.
|
HttpRequestIntent |
httpRequestIntent()
Provides an http request intent, this does not include the execution of it.
|
@Nullable T deserialize(HttpResponse httpResponse)
canDeserialize(HttpResponse)
if the response can be consumed.httpResponse
- the http response of the APIHttpRequestIntent httpRequestIntent()
default boolean canDeserialize(HttpResponse httpResponse)
deserialize(HttpResponse)
.
Use case 1: A http response returns 404 and the this SphereRequest
can handle this error by returning an empty optional, an empty list or throwing a domain specific exception.httpResponse
- the http response which shall be transformed