Class ContentResponse<C extends AssetObject>

java.lang.Object
com.oracle.content.sdk.ContentResponse<C>
All Implemented Interfaces:
Serializable

public class ContentResponse<C extends AssetObject> extends Object implements Serializable
Encapsulates an SDK response, including the deserialized result object and raw json.

Although the SDK provides a de-serialized java object (getResult(), you can deserialize the result yourself by using the raw json from getAsJson().

You can also get the ContentResponse.CacheState for the call to determine if the result came from the cache or network.
See Also:
  • Constructor Details

    • ContentResponse

      public ContentResponse(retrofit2.Response<com.google.gson.JsonElement> response)
      Construct the response resultObject
      Parameters:
      response - Retrofit response
    • ContentResponse

      public ContentResponse(okhttp3.Headers headers)
      Construct a response with a custom set of headers
      Parameters:
      headers - to use
    • ContentResponse

      public ContentResponse(ContentException exception)
      Construct the REST response resultObject (error case)
      Parameters:
      exception - ContentException because the call failed
  • Method Details

    • setResult

      public void setResult(C resultObject)
    • getResult

      public C getResult()
    • setException

      public void setException(ContentException exception)
    • getCacheState

      public ContentResponse.CacheState getCacheState()
      Get the current cache state of this resultObject, for example whether is from the network or cache.
      Returns:
      cache state of the returned resultObject
    • getHttpCode

      public int getHttpCode()
      Get HTTP code for the response
      Returns:
      httpCode such as 404
    • getHeaders

      public okhttp3.Headers getHeaders()
      Get response headers
      Returns:
      return headers from the response
    • getAsJson

      public com.google.gson.JsonElement getAsJson()
      Get response body as a JsonElement, or null in the case of an error
      Returns:
      return body of response as json element
    • isSuccess

      public boolean isSuccess()
      Is the response the result of a successful request? If not, then get more detailed errors from getException()
      Returns:
      true if call was successful
    • getException

      public ContentException getException()
      Get the ContentException condition in the case there was an error
      Returns:
      ContentException