MapConfiguration extends AbstractConfiguration { public static MapConfiguration merge(Configuration ... configs) { MapConfiguration mergedConfig = new MapConfiguration(); for (Configuration c : configs) { for (String key : c.getKeys()) { if (!mergedConfig.containsKey(key)) { mergedConfig.setProperty(key, c.getProperty(key)); } } } return mergedConfig; } MapConfiguration();  MapConfiguration(Map<String, String> configMap);  MapConfiguration(Configuration config); @Override Configuration subset(String prefix); @Override Configuration strippedSubset(String prefix); static MapConfiguration merge(Configuration ... configs); @Override boolean isEmpty(); @Override boolean containsKey(String key); @Override void setProperty(String key, String value); @Override void clear(); @Override void clearProperty(String key); @Override Iterable<String> getKeys(); @Override String getProperty(String key); @Override String getProperty(String key, String defaultValue); @Override String toString();  }
@Test public void testMerge() { config.setProperty("x.1", "y"); config.setProperty("x.2", "y"); Configuration config2 = new MapConfiguration(); config2.setProperty("a.1", "b"); config2.setProperty("x.1", "b"); Configuration mergedConfig = MapConfiguration.merge(config, config2); assertNotSame(config, mergedConfig); Set<String> keySet = (Set<String>) mergedConfig.getKeys(); assertEquals(new HashSet<>(Arrays.asList("x.1", "x.2", "a.1")), keySet); assertEquals("y", mergedConfig.getProperty("x.1")); }