I know how to “transform” a simple Java List
from Y
-> Z
, i.e.:
List<String> x;
List<Integer> y = x.stream()
.map(s -> Integer.parseInt(s))
.collect(Collectors.toList());
Now I’d like to do basically the same with a Map, i.e.:
INPUT:
{
"key1" -> "41", // "41" and "42"
"key2" -> "42" // are Strings
}
OUTPUT:
{
"key1" -> 41, // 41 and 42
"key2" -> 42 // are Integers
}
The solution should not be limited to String
-> Integer
. Just like in the List
example above, I’d like to call any method (or constructor).