Class RipResponse<T>

java.lang.Object
com.shri.restinpeace.RipResponse<T>
Type Parameters:
T - the decoded body type

public final class RipResponse<T> extends Object
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 Details

    • RipResponse

      public RipResponse(int status, Map<String,List<String>> headers, T body)
      Wraps a decoded response body with its status code and headers.
      Parameters:
      status - the HTTP response status code
      headers - 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

      public Map<String,List<String>> 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 null value
    • getHeader

      public String getHeader(String name)
      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 null if it wasn't sent
    • getBody

      public T getBody()
      Returns the decoded response body.
      Returns:
      the decoded response body