Skip to content

Instantly share code, notes, and snippets.

@aplz
Last active August 9, 2017 11:04
Show Gist options
  • Save aplz/85fb232e9244ee435b56012fe21a5020 to your computer and use it in GitHub Desktop.
Save aplz/85fb232e9244ee435b56012fe21a5020 to your computer and use it in GitHub Desktop.
List<Map<String, Object>> listOfMaps = Lists.newArrayList();
listOfMaps.add(ImmutableMap.of("a",1));
listOfMaps.add(ImmutableMap.of("b",1));
listOfMaps.add(ImmutableMap.of("b",1));
List<String> allKeys = listOfMaps.stream()
.flatMap(map -> map.keySet().stream())
.collect(Collectors.toList());
assertThat(allKeys, Matchers.containsInAnyOrder("a","b","b"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment