MetadataCollection extends ArrayList<MetadataElement> { public static Properties asProperties(Collection<MetadataElement> col) { Properties result = new Properties(); if (col == null) return result; for (MetadataElement e : col) { result.setProperty(e.getKey(), e.getValue()); } return result; } MetadataCollection();  MetadataCollection(@NotNull Set<MetadataElement> elements);  MetadataCollection(@NotNull MetadataCollection metadataCollection);  MetadataCollection(@NotNull KeyValuePairBag elements);  MetadataCollection(@NotNull Map<String, String> elements);  MetadataCollection(@NotNull MetadataElement... elements); Set<MetadataElement> toSet(); boolean containsKey(String key); static Set<MetadataElement> asSet(Collection<MetadataElement> col); static Properties asProperties(Collection<MetadataElement> col); static Map<String, String> asMap(Collection<MetadataElement> col);  }
@Test public void testAsProperties() { Set<MetadataElement> elements = new HashSet<>(); elements.add(new MetadataElement("test", "value")); Properties p = MetadataCollection.asProperties(elements); assertEquals("value", p.getProperty("test")); assertEquals(0, MetadataCollection.asProperties(null).size()); }