class RestAuthChoiceCallbackHandler extends AbstractRestAuthCallbackHandler<ChoiceCallback> {

    public JsonValue convertToJson(ChoiceCallback callback, int index) {

        String prompt = callback.getPrompt();
        String[] choices = callback.getChoices();
        int defaultChoice = callback.getDefaultChoice();
        int[] selectedIndexes = callback.getSelectedIndexes();
        int selectedIndex = 0;
        if (selectedIndexes != null) {
            selectedIndex = selectedIndexes[0];
        }

        JsonValue jsonValue = JsonValueBuilder.jsonValue()
                .put("type", CALLBACK_NAME)
                .array("output")
                .add(createOutputField("prompt", prompt))
                .add(createOutputField("choices", choices))
                .addLast(createOutputField("defaultChoice", defaultChoice))
                .array("input")
                .addLast(createInputField(index, selectedIndex))
                .build();

        return jsonValue;

    }

}