示例#1
0
 public final void setSettings(List<SettingDto> settings) {
   this.settings = new ArrayList<>();
   for (SettingDto setting : settings) {
     this.settings.add(setting.copy());
   }
   extendOptionsIfNecessary();
 }
示例#2
0
  private void extendOptionsIfNecessary() {
    // don't add null or empty string, only for list types
    if (!canExtendOptions()) {
      return;
    }

    // find the correct option
    SettingDto listValuesOption = getSettingByName(FORM_VALUES);

    // add the value
    if (listValuesOption != null) {
      if (listValuesOption.getValue() instanceof List) {
        // copy current values to avoid running into unmodifiable lists
        List listValues = new ArrayList((List) listValuesOption.getValue());
        // for lists, we add all not included
        if (List.class.isAssignableFrom(value.getClass())) {
          for (Object objectFromValueList : (List) value) {
            if (!listValues.contains(objectFromValueList.toString())) {
              listValues.add(objectFromValueList);
            }
          }
          // a case for single select comboboxes, just add the value
        } else {
          if (!listValues.contains(value.toString())) {
            listValues.add(value);
          }
        }
        listValuesOption.setValue(listValues);
      }
    }
  }
示例#3
0
 @JsonIgnore
 public final SettingDto getSettingByName(String name) {
   if (CollectionUtils.isNotEmpty(settings)) {
     for (SettingDto setting : settings) {
       if (StringUtils.equals(setting.getName(), name)) {
         return setting;
       }
     }
   }
   return null;
 }
示例#4
0
 private boolean isMultiSelect() {
   SettingDto setting = getSettingByName(MULTISELECT);
   return setting != null && Boolean.TRUE.equals(setting.getValue());
 }