Created
March 14, 2017 15:33
-
-
Save mikebroberts/19e4cd5bab32d5b4146ea065678e4bb6 to your computer and use it in GitHub Desktop.
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
package io.symphonia; | |
import java.util.ArrayList; | |
import java.util.HashMap; | |
import java.util.List; | |
import java.util.Map; | |
public class ListMapLambda { | |
public List<Integer> handlerList(List<Integer> input) { | |
List<Integer> newList = new ArrayList<>(); | |
input.forEach(x -> newList.add(100 + x)); | |
return newList; | |
} | |
public Map<String,String> handlerMap(Map<String,String> input) { | |
Map<String, String> newMap = new HashMap<>(); | |
input.forEach((k, v) -> newMap.put("New Map -> " + k, v)); | |
return newMap; | |
} | |
public Map<String,Map<String, Integer>> handlerNestedCollection(List<Map<String, Integer>> input) { | |
Map<String, Map<String, Integer>> newMap = new HashMap<>(); | |
IntStream.range(0, input.size()) | |
.forEach(i -> newMap.put("Nested at position " + i, input.get(i))); | |
return newMap; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment