class RestAuthChoiceCallbackHandler extends AbstractRestAuthCallbackHandler<ChoiceCallback> {

    public ChoiceCallback convertFromJson(ChoiceCallback callback, JsonValue jsonCallback) throws RestAuthException {

        validateCallbackType(CALLBACK_NAME, jsonCallback);

        JsonValue input = jsonCallback.get("input");

        if (input.size() != 1) {
            throw new JsonException("JSON Callback does not include a input field");
        }

        JsonValue inputField = input.get(0);
        int selectedIndex = toInteger(inputField.get("value"));

        callback.setSelectedIndex(selectedIndex);

        return callback;
    }

}