Properties extends HashMap<String, Object> { @Override public Object put(final String name, final Object value) { if (null != name) { if (null == value) { return super.remove(name); } else { return super.put(name, value); } } return null; } Properties();  Properties(final Map<String, Object> properties);  Properties(final String name, final Object property); @Override Object put(final String name, final Object value); @Override Properties clone(); void keepOnly(final Collection<String> propertiesToKeep); void remove(final Collection<String> propertiesToRemove); @Override String toString();  }
@Test public void shouldConstructPropertiesWithOtherProperties() { final Map<String, Object> otherProperties = new HashMap<>(); otherProperties.put("propertyName", "property value"); final Properties properties = new Properties(otherProperties); assertEquals(1, properties.size()); assertEquals("property value", properties.get("propertyName")); }
@Test public void shouldRemovePropertyIfAddedWithNullValue() { final Properties properties = new Properties(); properties.put("property1", "propertyValue1"); properties.put("property2", "propertyValue2"); properties.put("property1", null); assertEquals(1, properties.size()); assertEquals(null, properties.get("property1")); }
@Test public void shouldNotAddPropertyIfPropertyNameIsNull() { final Properties properties = new Properties(); properties.put(null, "propertyValue1"); assertEquals(0, properties.size()); }