Package com.loop54.model.response
Class Response
java.lang.Object
com.loop54.model.response.Response
- Direct Known Subclasses:
AutoCompleteResponse,ErrorResponse,GetBasketRecommendationsResponse,GetComplementaryEntitiesResponse,GetEntitiesByAttributeResponse,GetEntitiesResponse,GetPopularEntitiesResponse,GetRecentEntitiesResponse,GetRecommendedEntitiesResponse,GetRelatedEntitiesResponse,SearchResponse
A response from the engine. Used for responses that don't return any standardized data parameters.
-
Field Summary
FieldsModifier and TypeFieldDescriptionAny additional, non-standard, data. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> TgetCustomDataOrDefault(String key, Class<T> clazz) Retrieve a named custom value from the response.<T> TgetCustomDataOrThrow(String key, Class<T> clazz) Retrieve a named custom value from the response.
-
Field Details
-
customData
Any additional, non-standard, data. Contact support for information about how and when to use this.
-
-
Constructor Details
-
Response
public Response()
-
-
Method Details
-
getCustomDataOrThrow
Retrieve a named custom value from the response. If not found, or the value could not be deserialized or cast to T, it will throw an exception.- Type Parameters:
T- Expected type of the response data to retrieve.- Parameters:
key- Key of the custom data.clazz- Expected class of the response data to retrieve.- Returns:
- Deserialized data as the specified type, if it exists.
- Throws:
Loop54Exception- If not found, or the value could not be deserialized to the desired class.
-
getCustomDataOrDefault
Retrieve a named custom value from the response. If not found it will return the default value. If the value could not be deserialized or cast to T it will throw an exception.- Type Parameters:
T- Expected type of the response data to retrieve.- Parameters:
key- Key of the custom data.clazz- Expected class of the response data to retrieve.- Returns:
- Deserialized data as the specified type. If the data did not exist null is returned.
- Throws:
Loop54Exception- if the value cannot be deserialized to the desired class.
-