@@ -0,0 +1,2140 @@
+package io.asfjava.ui.core.generators;%0A%0Aimport java.lang.reflect.Field;%0Aimport java.util.Map;%0A%0Aimport com.fasterxml.jackson.databind.ObjectMapper;%0Aimport com.fasterxml.jackson.databind.node.ArrayNode;%0Aimport com.fasterxml.jackson.databind.node.ObjectNode;%0A%0Aimport io.asfjava.ui.core.form.CheckBox;%0Aimport io.asfjava.ui.core.form.TitleMapsAdapter;%0A%0Apublic class CheckBoxGenerator implements FormDefinitionGenerator %7B%0A%0A%09@Override%0A%09public void generate(ObjectNode fieldFormDefinition, Field field) %7B%0A%09%09CheckBox annotation = field.getAnnotation(CheckBox.class);%0A%09%09fieldFormDefinition.put(%22key%22, field.getName());%0A%09%09fieldFormDefinition.put(%22type%22, %22checkboxes%22);%0A%09%09fieldFormDefinition.put(%22multiple%22, annotation.multiple());%0A%09%09fieldFormDefinition.put(%22required%22, annotation.required());%0A%09%09ObjectMapper checkBoxMapper = new ObjectMapper();%0A%09%09ArrayNode titlesMap = checkBoxMapper.createArrayNode();%0A%09%09String%5B%5D checkBoxValues = annotation.values();%0A%09%09if (checkBoxValues.length != 0) %7B%0A%09%09%09for (String value : checkBoxValues) %7B%0A%09%09%09%09ObjectNode entry = checkBoxMapper.createObjectNode();%0A%09%09%09%09if (value.equals(value.toUpperCase())) %7B%0A%09%09%09%09%09entry.put(%22name%22, value.toLowerCase());%0A%09%09%09%09%7D else if (value.equals(value.toLowerCase())) %7B%0A%09%09%09%09%09entry.put(%22name%22, value.replace(value.substring(0, 1), value.substring(0, 1).toUpperCase()));%0A%09%09%09%09%7D else %7B%0A%09%09%09%09%09entry.put(%22name%22, value);%0A%09%09%09%09%7D%0A%09%09%09%09entry.put(%22value%22, value);%0A%09%09%09%09titlesMap.add(entry);%0A%09%09%09%7D%0A%09%09%09fieldFormDefinition.set(%22titleMap%22, titlesMap);%0A%09%09%7D else if (!annotation.titleMap().equals(TitleMapsAdapter.class)) %7B%0A%0A%09%09%09try %7B%0A%09%09%09%09Map%3CString, Object%3E map = (annotation.titleMap()).newInstance().getPossibleValues();%0A%0A%09%09%09%09for (Map.Entry%3CString, Object%3E iterator : map.entrySet()) %7B%0A%09%09%09%09%09ObjectNode entry = checkBoxMapper.createObjectNode();%0A%09%09%09%09%09entry.put(%22name%22, iterator.getKey());%0A%09%09%09%09%09entry.putPOJO(%22value%22, iterator.getValue());%0A%09%09%09%09%09titlesMap.add(entry);%0A%09%09%09%09%7D%0A%09%09%09%09fieldFormDefinition.set(%22titleMap%22, titlesMap);%0A%09%09%09%7D catch (InstantiationException %7C IllegalAccessException e) %7B%0A%09%09%09%09e.printStackTrace();%0A%09%09%09%7D%0A%09%09%7D%09%09%0A%09%7D%0A%0A%09@Override%0A%09public String getAnnoation() %7B%0A%09%09return CheckBox.class.getName();%0A%09%7D%0A%0A%7D%0A

Create CheckBoxGenerator.java