Created
July 5, 2016 08:45
-
-
Save darekmydlarz/e2b0e2ffefcf272d9eba78434217d143 to your computer and use it in GitHub Desktop.
Java 8 vs Java pre-8
This file contains hidden or 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
| 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