/** * Replace the value(s) for the key with a new value. * * @param key the key for the section * @param value the value for the key * @return whether the replace happened */ public boolean replace(String key, String value) { if (!allowed(key, value)) { return false; } Collection<String> values = getOrCreateValues(key); values.clear(); return values.add(value); }
/** * Add a value for the key. Duplicate values are not allowed. * * @param key the key for the section * @param value the value for the key * @return whether the value was added or is already present. */ public boolean add(String key, String value) { if (!allowed(key, value)) { return false; } Collection<String> values = getOrCreateValues(key); if (values.contains(value)) { warnings.append("Duplicate value: ").append(key).append(" = ").append(value).append('\n'); return true; } return values.add(value); }