Package com.oracle.content.sdk
Class ContentResponse<C extends AssetObject>
java.lang.Object
com.oracle.content.sdk.ContentResponse<C>
- All Implemented Interfaces:
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()
.
ContentResponse.CacheState
for the call to determine
if the result came from the cache or network.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
The state of the response, such as whether it came from network or cached. -
Constructor Summary
ConstructorsConstructorDescriptionContentResponse
(ContentException exception) Construct the REST response resultObject (error case)ContentResponse
(okhttp3.Headers headers) Construct a response with a custom set of headersContentResponse
(retrofit2.Response<com.google.gson.JsonElement> response) Construct the response resultObject -
Method Summary
Modifier and TypeMethodDescriptioncom.google.gson.JsonElement
Get response body as a JsonElement, or null in the case of an errorGet the current cache state of this resultObject, for example whether is from the network or cache.Get the ContentException condition in the case there was an errorokhttp3.Headers
Get response headersint
Get HTTP code for the responseboolean
Is the response the result of a successful request? If not, then get more detailed errors fromgetException()
void
setException
(ContentException exception) void
-
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
Construct the REST response resultObject (error case)- Parameters:
exception
-ContentException
because the call failed
-
-
Method Details
-
setResult
-
getResult
-
setException
-
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 fromgetException()
- Returns:
- true if call was successful
-
getException
Get the ContentException condition in the case there was an error- Returns:
ContentException
-