Skip to content
Snippets Groups Projects
Commit d04c7f03 authored by Peter van 't Hof's avatar Peter van 't Hof
Browse files

Added resolveConflict option to mergeMaps

parent 52a36f28
No related branches found
No related tags found
No related merge requests found
......@@ -33,7 +33,8 @@ object ConfigUtils extends Logging {
* @param map2 Backup for map1
* @return merged map
*/
def mergeMaps(map1: Map[String, Any], map2: Map[String, Any]): Map[String, Any] = {
def mergeMaps(map1: Map[String, Any], map2: Map[String, Any],
resolveConflict: (Any, Any, String) => Any = (m1, m2, key) => m1): Map[String, Any] = {
var newMap: Map[String, Any] = Map()
for (key <- map1.keySet.++(map2.keySet)) {
if (!map2.contains(key)) newMap += (key -> map1(key))
......@@ -46,7 +47,7 @@ object ConfigUtils extends Logging {
case _ => newMap += (key -> map1(key))
}
}
case _ => newMap += (key -> map1(key))
case _ => newMap += (key -> resolveConflict(map1(key), map2(key), key))
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment