Class ServiceResponse<T>

  • Type Parameters:
    T - the type of the response
    Direct Known Subclasses:
    ServiceResponseWithHeaders

    public class ServiceResponse<T>
    extends Object
    An instance of this class holds a response object and a raw REST response.
    • Constructor Detail

      • ServiceResponse

        public ServiceResponse​(T body,
                               retrofit2.Response<okhttp3.ResponseBody> response)
        Instantiate a ServiceResponse instance with a response object and a raw REST response.
        Parameters:
        body - deserialized response object
        response - raw REST response
      • ServiceResponse

        public ServiceResponse​(retrofit2.Response<Void> headResponse)
        Instantiate a ServiceResponse instance with a response from a HEAD operation.
        Parameters:
        headResponse - raw REST response from a HEAD operation
    • Method Detail

      • body

        public T body()
        Gets the response object.
        Returns:
        the response object. Null if there isn't one.
      • withBody

        public ServiceResponse<T> withBody​(T body)
        Sets the response object.
        Parameters:
        body - the response object.
        Returns:
        the ServiceResponse object itself
      • response

        public retrofit2.Response<okhttp3.ResponseBody> response()
        Gets the raw REST response.
        Returns:
        the raw REST response.
      • headResponse

        public retrofit2.Response<Void> headResponse()
        Gets the raw REST response from a HEAD operation.
        Returns:
        the raw REST response from a HEAD operation.