Skip to content

Instantly share code, notes, and snippets.

@darekmydlarz
Created July 5, 2016 08:45
Show Gist options
  • Select an option

  • Save darekmydlarz/e2b0e2ffefcf272d9eba78434217d143 to your computer and use it in GitHub Desktop.

Select an option

Save darekmydlarz/e2b0e2ffefcf272d9eba78434217d143 to your computer and use it in GitHub Desktop.
Java 8 vs Java pre-8
void prejava8() throws MalformedUrlException {
Map<String, Cluster> clusters = Maps.newHashMap();
for (final Map<String, Object> clusterYml : clustersListYml) {
Cluster cluster = new HystrixCluster(clusterAdapter.fromMap(clusterYml));
clusters.put(cluster.name(), cluster);
}
return clusters;
}
void java8() {
return clustersListYml.stream()
.map(map -> {
try {
return new HystrixCluster(clusterAdapter.fromMap(map));
} catch (MalformedURLException e) {
throw new IllegalArgumentException(e);
}
})
.collect(Collectors.toMap(HystrixCluster::name, Function.identity()));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment