cjmctague commented on a change in pull request #902: fixes #894 merge SimpleConfiguration Objects URL: https://github.com/apache/fluo/pull/902#discussion_r131721901
########## File path: modules/api/src/main/java/org/apache/fluo/api/config/SimpleConfiguration.java ########## @@ -250,6 +277,22 @@ public SimpleConfiguration subset(String prefix) { return new SimpleConfiguration(internalConfig.subset(prefix)); } + /** + * @param SimpleConfigs SimpleConfiguration's to be merged + * @return SimpleConfiguration + * + * @since 1.2.0 + */ + public static SimpleConfiguration merge(SimpleConfiguration... simpleConfigs) { + SimpleConfiguration mrg = new SimpleConfiguration(); + for (SimpleConfiguration sc : simpleConfigs) { + for (Map.Entry<String, String> entry : sc.toMap().entrySet()) { + mrg.addProperty(entry.getKey(), entry.getValue()); Review comment: ``` SimpleConfiguration sc1 = new SimpleConfiguration(); sc1.setProperty("set1", "value1"); sc1.setProperty("set1", "value2"); sc1.setProperty("set3", "value3"); SimpleConfiguration sc2 = new SimpleConfiguration(); sc2.addProperty("add1", "value4"); sc2.addProperty("add1", "value5"); sc2.addProperty("add3", "value6"); SimpleConfiguration sc3 = new SimpleConfiguration(); SimpleConfiguration empty = new SimpleConfiguration(); SimpleConfiguration msc = SimpleConfiguration.merge(sc1, sc2, sc3); msc: <[set1=value2 set3=value3 add1=[value4, value5] add3=value6]> ``` I was playing around with the `setProperty()` and `addProperty()` and you are correct, `addProperty()` does create a list while `setProperty()` overwrites the value of anything with the same key. Note how we lose `value1` in this example. Is that acceptable? In my mind that's not really a merge but rather a rewrite of the property if they have the same key value. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services