public void setKeyValueString(List<String> lines) {
    if (lines == null) {
      return;
    }
    allKeyValueMap = new HashMap<>();
    allRegExKeys = new HashMap<>();
    RegexValidation regexValidation = new RegexValidation();
    regexValidation.setExpression("\\^\\((([a-zA-Z0-9_]+[|]+)*)[a-zA-Z0-9_]+\\)\\$"); // $NON-NLS-1$
    String[] splitLine;
    for (String line : lines) {
      if (line.isEmpty()) {
        continue;
      }
      splitLine = line.split(KEY_VALUE_DELIMETER, 2);
      String key = splitLine[0];
      allKeyValueMap.put(key, splitLine[1]);
      ValidationResult valid = regexValidation.validate(allKeyValueMap.get(key));
      if (valid.getSuccess()) {
        String[] values =
            allKeyValueMap
                .get(key)
                .substring(2, allKeyValueMap.get(key).length() - 2)
                .split("\\|"); // $NON-NLS-1$
        allRegExKeys.put(key, Arrays.asList(values));
      }
    }

    deserialize(saveEntity);
  }
Exemple #2
0
 private void validateListItems(ListModel<?> listModel) {
   ValidationResult result = new NotEmptyValidation().validate(listModel.getSelectedItem());
   listModel.setIsValid(result.getSuccess());
   listModel.getInvalidityReasons().addAll(result.getReasons());
 }