TypedProperties { public void put(String key, Object value) { Map.Entry<String, List<String>> oldEntry = _storage.get(key); List<String> values = null; if (oldEntry != null) { Object oldObject = _convertFromString(oldEntry.getKey()); if (Objects.equals(oldObject, value)) { values = oldEntry.getValue(); } else { Class<?> clazz = value.getClass(); if (clazz.isArray() && Objects.deepEquals(oldObject, value)) { values = oldEntry.getValue(); } } } _storage.put( key, new AbstractMap.SimpleImmutableEntry<>( _convertToString(value), values)); }  Object get(String key); Set<String> keySet(); void load(Reader reader); void put(String key, Object value); void remove(String key); void save(Writer writer);  }
@Test public void testLoadPutandSaveMultiline() throws IOException { String line = "testKey = [\\\n\t\"testValue1\",\\\n\t\"testValue2\"\\\n]"; TypedProperties typedProperties = _createTypedProperties(line); typedProperties.put( "testKey", new String[] {"testValue1", "testValue2"}); _assertSave(typedProperties, line); }
@Test public void testPutandSave() throws IOException { TypedProperties typedProperties = new TypedProperties(); typedProperties.put("testKey", "testValue"); _assertSave(typedProperties, "testKey = \"testValue\""); }