Package com.shopify.graphql.support
Interface CustomFieldInterface
-
public interface CustomFieldInterfaceIn order to allow custom fields from being "gettable" via java interface classes, this class defines all the getter methods for custom fields. Note that all these methods are already implemented inAbstractResponseso they are immediately available to all interfaces.
-
-
Method Summary
All Methods Instance Methods Default Methods Modifier and Type Method Description default Objectget(String field)Gets a field as a raw object.default com.google.gson.JsonArraygetAsArray(String field)Tries to deserialise and return the given JSON field as an Array.default BooleangetAsBoolean(String field)Tries to deserialise and return the given JSON field as a Boolean.default DoublegetAsDouble(String field)Tries to deserialise and return the given JSON field as a Double.default IntegergetAsInteger(String field)Tries to deserialise and return the given JSON field as an Integer.default StringgetAsString(String field)Tries to deserialise and return the given JSON field as a String.
-
-
-
Method Detail
-
get
default Object get(String field)
Gets a field as a raw object.- Parameters:
field- The name of the field.- Returns:
- The raw object.
-
getAsString
default String getAsString(String field) throws SchemaViolationError
Tries to deserialise and return the given JSON field as a String. The field itself is expected to be stored in the object data as aJsonElement, which is the case for custom simple fields.- Parameters:
field- The name of the field.- Returns:
- The value of the field.
- Throws:
SchemaViolationError- If the field cannot be converted to a String.
-
getAsInteger
default Integer getAsInteger(String field) throws SchemaViolationError
Tries to deserialise and return the given JSON field as an Integer. The field itself is expected to be stored in the object data as aJsonElement, which is the case for custom simple fields.- Parameters:
field- The name of the field.- Returns:
- The value of the field.
- Throws:
SchemaViolationError- If the field cannot be converted to an Integer.
-
getAsDouble
default Double getAsDouble(String field) throws SchemaViolationError
Tries to deserialise and return the given JSON field as a Double. The field itself is expected to be stored in the object data as aJsonElement, which is the case for custom simple fields.- Parameters:
field- The name of the field.- Returns:
- The value of the field.
- Throws:
SchemaViolationError- If the field cannot be converted to a Double.
-
getAsBoolean
default Boolean getAsBoolean(String field) throws SchemaViolationError
Tries to deserialise and return the given JSON field as a Boolean. The field itself is expected to be stored in the object data as aJsonElement, which is the case for custom simple fields.- Parameters:
field- The name of the field.- Returns:
- The value of the field.
- Throws:
SchemaViolationError- If the field cannot be converted to a Boolean.
-
getAsArray
default com.google.gson.JsonArray getAsArray(String field) throws SchemaViolationError
Tries to deserialise and return the given JSON field as an Array. The field itself is expected to be stored in the object data as aJsonElement, which is the case for custom simple fields.- Parameters:
field- The name of the field.- Returns:
- The value of the field.
- Throws:
SchemaViolationError- If the field cannot be converted to an Array.
-
-