class RestAuthLanguageCallbackHandler extends AbstractRestAuthCallbackHandler<LanguageCallback> {

    public JsonValue convertToJson(LanguageCallback callback, int index) {

        Locale locale = callback.getLocale();

        JsonObject jsonObject = JsonValueBuilder.jsonValue()
                .put("type", CALLBACK_NAME);

        if (locale != null) {
            jsonObject.array("input")
                    .add(createInputField(index, "Language", locale.getLanguage()))
                    .addLast(createInputField(index, "Country", locale.getCountry()));
        }

        return jsonObject.build();
    }

}