@Override public PropertyValue removeProperty(String key) { return this.properties != null ? properties.remove(key) : null; }
/** * Removes the given property from the list. * * @param property property * @return the previous value associated with <tt>key</tt>, or * <tt>null</tt> if there was no mapping for <tt>key</tt>. */ public PropertyValue remove(Property property) { Objects.requireNonNull(property); return remove(property.getKey()); }
@Test public void testRemove() throws Exception { Properties properties = Properties.create(); PropertyValue removed; properties.set(KEY_1, BOOL_VAL_1); removed = properties.remove(KEY_1); assertEquals(0, properties.size()); assertNotNull(removed); properties.set(KEY_1, BOOL_VAL_1); removed = properties.remove(KEY_2); assertEquals(1, properties.size()); assertNull(removed); }
@Test public void testRemove2() throws Exception { Properties properties = Properties.create(); PropertyValue removed; properties.set(KEY_1, BOOL_VAL_1); removed = properties.remove(Property.create(KEY_1, BOOL_VAL_1)); assertEquals(0, properties.size()); assertNotNull(removed); properties.set(KEY_1, BOOL_VAL_1); removed = properties.remove(Property.create(KEY_2, BOOL_VAL_1)); assertEquals(1, properties.size()); assertNull(removed); }