KeyValuePairSet extends KeyValuePairBag implements Set<KeyValuePair>, Serializable { @Override public void addKeyValuePair(KeyValuePair pair) { Args.notNull(pair, "keyValuePair"); if (getKeyValuePairs().contains(pair)) { getKeyValuePairs().remove(pair); } add(pair); } KeyValuePairSet();  KeyValuePairSet(Collection<KeyValuePair> pairs);  KeyValuePairSet(Properties properties);  KeyValuePairSet(Map<String, String> map); @Override Set<KeyValuePair> getKeyValuePairs(); @Override void addKeyValuePair(KeyValuePair pair); @Override boolean equals(Object o); @Override boolean removeAll(Collection<?> c);  }
@Test public void testAddTheSame() { KeyValuePairSet set = new KeyValuePairSet(); set.addKeyValuePair(new KeyValuePair(KEY1, VALUE1)); set.addKeyValuePair(new KeyValuePair(KEY1, VALUE1)); set.addKeyValuePair(new KeyValuePair(KEY1, "")); assertEquals(1, set.size()); }
@Test public void testCollectionConstructor() { KeyValuePairSet set = new KeyValuePairSet(); set.addKeyValuePair(new KeyValuePair(KEY1, VALUE1)); set.addKeyValuePair(new KeyValuePair(KEY2, VALUE2)); set.addKeyValuePair(new KeyValuePair("key3", "value3")); KeyValuePairSet set2 = new KeyValuePairSet(set); assertEquals(set, set2); assertEquals(set.hashCode(), set2.hashCode()); }