Package com.shri.restinpeace
Class RipResponse<T>
java.lang.Object
com.shri.restinpeace.RipResponse<T>
- Type Parameters:
T- the decoded body type
Wraps a successful response's decoded body together with its status code
and headers, for a method that needs more than just the body. Declare it
as a method's return type (or
CompletableFuture<RipResponse<T>>
for an async method) instead of T directly:
@GET("/users/{id}")
RipResponse<User> getUser(@PathParam("id") String id);
T is decoded exactly as it would be for a plain return type -
String for the raw body, Void to discard it, anything else
deserialized from JSON. A non-2xx response still throws
RestInPeaceHttpException instead of
producing a RipResponse - this type only ever describes a
successful response.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetBody()Returns the decoded response body.Returns the first value of a response header, since most headers only ever carry one.Returns the response headers.intReturns the HTTP response status code.
-
Constructor Details
-
RipResponse
Wraps a decoded response body with its status code and headers.- Parameters:
status- the HTTP response status codeheaders- the response headers, keyed by name (case-insensitively)body- the decoded response body
-
-
Method Details
-
getStatus
public int getStatus()Returns the HTTP response status code.- Returns:
- the HTTP response status code
-
getHeaders
Returns the response headers.- Returns:
- the response headers, keyed by name (case-insensitively); a
name absent from the response maps to no entry, not a
nullvalue
-
getHeader
Returns the first value of a response header, since most headers only ever carry one.- Parameters:
name- the header name, matched case-insensitively- Returns:
- the header's first value, or
nullif it wasn't sent
-
getBody
Returns the decoded response body.- Returns:
- the decoded response body
-