T - the type of the result of this requestpublic abstract class SphereRequestDecorator<T> extends Base implements SphereRequest<T>
SphereRequests.| Modifier and Type | Field and Description |
|---|---|
protected SphereRequest<T> |
delegate |
| Modifier | Constructor and Description |
|---|---|
protected |
SphereRequestDecorator(SphereRequest<T> delegate) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
canDeserialize(HttpResponse httpResponse)
Checks if the response can be handled by
SphereRequest.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.
|
protected final SphereRequest<T> delegate
protected SphereRequestDecorator(SphereRequest<T> delegate)
public boolean canDeserialize(HttpResponse httpResponse)
SphereRequestSphereRequest.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.canDeserialize in interface SphereRequest<T>httpResponse - the http response which shall be transformedpublic HttpRequestIntent httpRequestIntent()
SphereRequesthttpRequestIntent in interface SphereRequest<T>public T deserialize(HttpResponse httpResponse)
SphereRequestSphereRequest.canDeserialize(HttpResponse) if the response can be consumed.deserialize in interface SphereRequest<T>httpResponse - the http response of the API