Last active
April 6, 2019 21:47
-
-
Save DaddyMoe/316b6f90b36207b11d0e5b73874a6be1 to your computer and use it in GitHub Desktop.
Merge two Maps together of type: Map<String, List<String>>
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Merge two Maps together of type: Map<String, List<String>> | |
static BiFunction<Map<String, List<String>>, Map<String, List<String>>, Map<String, List<String>>> mergeMaps() { | |
return (Map<String, List<String>> map1, Map<String, List<String>> map2) -> { | |
Map<String, List<String>> mergedMapped = new HashMap<>(map1); | |
map2.forEach((String k, List<String> v) -> mergedMapped.merge(k, v, (strings, strings2) -> { | |
strings.addAll(strings2); | |
return strings; | |
}) | |
); | |
return mergedMapped; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment