Interface CustomFieldInterface


  • public interface CustomFieldInterface
    In 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 in AbstractResponse so they are immediately available to all interfaces.
    • 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 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

        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 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

        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 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

        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 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

        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 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.