@Test public void testOldSyntax() throws Exception { ConfigurationFactory factory = new ConfigurationFactory(); Configuration configuration = factory.getConfiguration(getOldSyntaxConfigProps()); assertEquals(2, configuration.getProperties().size()); Map<String, String> configProperties1 = configuration.getProperties().get("foo-type"); assertEquals(2, configProperties1.size()); assertEquals("prop1Value", configProperties1.get("prop1")); assertEquals("prop2Value", configProperties1.get("prop2")); Map<String, String> configProperties2 = configuration.getProperties().get("bar-type"); assertEquals(1, configProperties2.size()); assertEquals("prop3Value", configProperties2.get("prop3")); assertTrue(configuration.getAttributes().isEmpty()); }
public Configuration getConfiguration(Collection<Map<String, String>> configProperties) { Map<String, Map<String, String>> properties = new HashMap<String, Map<String, String>>(); Map<String, Map<String, Map<String, String>>> attributes = new HashMap<String, Map<String, Map<String, String>>>(); Configuration configuration = new Configuration(properties, attributes); if (configProperties != null) { for (Map<String, String> typeMap : configProperties) { ConfigurationStrategy strategy = decidePopulationStrategy(typeMap); for (Map.Entry<String, String> entry : typeMap.entrySet()) { String[] propertyNameTokens = entry.getKey().split("/"); strategy.setConfiguration(configuration, propertyNameTokens, entry.getValue()); } } } return configuration; }
ConfigurationFactory { public Configuration getConfiguration(Collection<Map<String, String>> configProperties) { Map<String, Map<String, String>> properties = new HashMap<String, Map<String, String>>(); Map<String, Map<String, Map<String, String>>> attributes = new HashMap<String, Map<String, Map<String, String>>>(); Configuration configuration = new Configuration(properties, attributes); if (configProperties != null) { for (Map<String, String> typeMap : configProperties) { ConfigurationStrategy strategy = decidePopulationStrategy(typeMap); for (Map.Entry<String, String> entry : typeMap.entrySet()) { String[] propertyNameTokens = entry.getKey().split("/"); strategy.setConfiguration(configuration, propertyNameTokens, entry.getValue()); } } } return configuration; } }
ConfigurationFactory { public Configuration getConfiguration(Collection<Map<String, String>> configProperties) { Map<String, Map<String, String>> properties = new HashMap<String, Map<String, String>>(); Map<String, Map<String, Map<String, String>>> attributes = new HashMap<String, Map<String, Map<String, String>>>(); Configuration configuration = new Configuration(properties, attributes); if (configProperties != null) { for (Map<String, String> typeMap : configProperties) { ConfigurationStrategy strategy = decidePopulationStrategy(typeMap); for (Map.Entry<String, String> entry : typeMap.entrySet()) { String[] propertyNameTokens = entry.getKey().split("/"); strategy.setConfiguration(configuration, propertyNameTokens, entry.getValue()); } } } return configuration; }  }
ConfigurationFactory { public Configuration getConfiguration(Collection<Map<String, String>> configProperties) { Map<String, Map<String, String>> properties = new HashMap<String, Map<String, String>>(); Map<String, Map<String, Map<String, String>>> attributes = new HashMap<String, Map<String, Map<String, String>>>(); Configuration configuration = new Configuration(properties, attributes); if (configProperties != null) { for (Map<String, String> typeMap : configProperties) { ConfigurationStrategy strategy = decidePopulationStrategy(typeMap); for (Map.Entry<String, String> entry : typeMap.entrySet()) { String[] propertyNameTokens = entry.getKey().split("/"); strategy.setConfiguration(configuration, propertyNameTokens, entry.getValue()); } } } return configuration; }  Configuration getConfiguration(Collection<Map<String, String>> configProperties); }
ConfigurationFactory { public Configuration getConfiguration(Collection<Map<String, String>> configProperties) { Map<String, Map<String, String>> properties = new HashMap<String, Map<String, String>>(); Map<String, Map<String, Map<String, String>>> attributes = new HashMap<String, Map<String, Map<String, String>>>(); Configuration configuration = new Configuration(properties, attributes); if (configProperties != null) { for (Map<String, String> typeMap : configProperties) { ConfigurationStrategy strategy = decidePopulationStrategy(typeMap); for (Map.Entry<String, String> entry : typeMap.entrySet()) { String[] propertyNameTokens = entry.getKey().split("/"); strategy.setConfiguration(configuration, propertyNameTokens, entry.getValue()); } } } return configuration; }  Configuration getConfiguration(Collection<Map<String, String>> configProperties);  }