Class AbstractResponse<T extends AbstractResponse>

    • Constructor Detail

      • AbstractResponse

        public AbstractResponse()
    • Method Detail

      • withAlias

        public T withAlias​(String aliasSuffix)
      • get

        public Object get​(String field)
        Gets a field as a raw object.
        Parameters:
        field - The name of the field.
        Returns:
        The raw object.
      • getAsString

        public 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 a JsonElement, 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

        public 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 a JsonElement, 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

        public 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 a JsonElement, 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

        public 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 a JsonElement, 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

        public 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 a JsonElement, 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.
      • readCustomField

        protected void readCustomField​(String fieldName,
                                       com.google.gson.JsonElement element)
                                throws SchemaViolationError
        Tries to read a custom field from the GraphQL JSON response. The method throws a schema violation exception if the field name does not contain the _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.
        Parameters:
        fieldName - The field name.
        element - The JSON element parsed by the JSON deserialiser.
        Throws:
        SchemaViolationError - If the field name does not contain the _custom_ suffix.
      • getFieldName

        protected String getFieldName​(String key)
      • collectNodes

        public List<Node> collectNodes()
      • unwrapsToObject

        public abstract boolean unwrapsToObject​(String key)