public abstract class AbstractResponse<T extends AbstractResponse> extends Object implements Serializable
| Modifier and Type | Field and Description |
|---|---|
HashMap<String,Object> |
optimisticData |
HashMap<String,Object> |
responseData |
| Constructor and Description |
|---|
AbstractResponse() |
| Modifier and Type | Method and Description |
|---|---|
List<Node> |
collectNodes() |
Object |
get(String field)
Gets a field as a raw object.
|
com.google.gson.JsonArray |
getAsArray(String field)
Tries to deserialise and return the given JSON field as an Array.
|
Boolean |
getAsBoolean(String field)
Tries to deserialise and return the given JSON field as a Boolean.
|
Double |
getAsDouble(String field)
Tries to deserialise and return the given JSON field as a Double.
|
Integer |
getAsInteger(String field)
Tries to deserialise and return the given JSON field as an Integer.
|
String |
getAsString(String field)
Tries to deserialise and return the given JSON field as a String.
|
protected String |
getFieldName(String key) |
protected String |
getKey(String field) |
protected com.google.gson.JsonArray |
jsonAsArray(com.google.gson.JsonElement element,
String field) |
protected Boolean |
jsonAsBoolean(com.google.gson.JsonElement element,
String field) |
protected Double |
jsonAsDouble(com.google.gson.JsonElement element,
String field) |
protected Integer |
jsonAsInteger(com.google.gson.JsonElement element,
String field) |
protected com.google.gson.JsonObject |
jsonAsObject(com.google.gson.JsonElement element,
String field) |
protected String |
jsonAsString(com.google.gson.JsonElement element,
String field) |
protected void |
readCustomField(String fieldName,
com.google.gson.JsonElement element)
Tries to read a custom field from the GraphQL JSON response.
|
abstract boolean |
unwrapsToObject(String key) |
T |
withAlias(String aliasSuffix) |
public Object get(String field)
field - The name of the field.public String getAsString(String field) throws SchemaViolationError
JsonElement, which is the case for custom simple fields.field - The name of the field.SchemaViolationError - If the field cannot be converted to a String.public Integer getAsInteger(String field) throws SchemaViolationError
JsonElement, which is the case for custom simple fields.field - The name of the field.SchemaViolationError - If the field cannot be converted to an Integer.public Double getAsDouble(String field) throws SchemaViolationError
JsonElement, which is the case for custom simple fields.field - The name of the field.SchemaViolationError - If the field cannot be converted to a Double.public Boolean getAsBoolean(String field) throws SchemaViolationError
JsonElement, which is the case for custom simple fields.field - The name of the field.SchemaViolationError - If the field cannot be converted to a Boolean.public com.google.gson.JsonArray getAsArray(String field) throws SchemaViolationError
JsonElement, which is the case for custom simple fields.field - The name of the field.SchemaViolationError - If the field cannot be converted to an Array.protected void readCustomField(String fieldName, com.google.gson.JsonElement element) throws SchemaViolationError
_custom_ alias suffix added by the library,
which would indicate that the field does not belong to the GraphQL Schema and was not explicitly requested
as a custom field.fieldName - The field name.element - The JSON element parsed by the JSON deserialiser.SchemaViolationError - If the field name does not contain the _custom_ suffix.protected String jsonAsString(com.google.gson.JsonElement element, String field) throws SchemaViolationError
SchemaViolationErrorprotected Integer jsonAsInteger(com.google.gson.JsonElement element, String field) throws SchemaViolationError
SchemaViolationErrorprotected Double jsonAsDouble(com.google.gson.JsonElement element, String field) throws SchemaViolationError
SchemaViolationErrorprotected Boolean jsonAsBoolean(com.google.gson.JsonElement element, String field) throws SchemaViolationError
SchemaViolationErrorprotected com.google.gson.JsonObject jsonAsObject(com.google.gson.JsonElement element,
String field)
throws SchemaViolationError
SchemaViolationErrorprotected com.google.gson.JsonArray jsonAsArray(com.google.gson.JsonElement element,
String field)
throws SchemaViolationError
SchemaViolationErrorpublic abstract boolean unwrapsToObject(String key)
Copyright © 2022 Adobe. All rights reserved.