class FormFunction {

   @FunctionMeta(description = "Show multiple checkboxes from a list or array object's properties in a form", example = "${w:showCheckboxes('groupBy', groupBys, payload.groupBy, 'name', 'description')}")
   public static String showCheckboxes(String inputName, Object items, Object selected, String valueName, String textName) {
      StringBuilder sb = new StringBuilder();

      if (items instanceof Object[]) {
         for (Object item : (Object[]) items) {
            sb.append(showCheckbox(inputName, item, selected, valueName, textName));
            sb.append("\r\n");
         }
      } else if (items instanceof List) {
         for (Object item : (List<?>) items) {
            sb.append(showCheckbox(inputName, item, selected, valueName, textName));
            sb.append("\r\n");
         }
      } else if (items != null) {
         throw new RuntimeException("Object[] or List expected, but was: " + items.getClass());
      }

      return sb.toString();
   }

}