I have the following method to map values in map:
public static <X, Y, Z> Map<X, Z> transformValues(Map<? extends X, ? extends Y> input, Function<Y, Z> function) {
return input.keySet().stream()
.collect(Collectors.toMap(Function.identity(),
key -> function.apply(input.get(key))));
}
It was suggested here: https://stackoverflow.com/a/25905196/411965
I want to create a similar method to SortedMap:
public static <X, Y, Z> SortedMap<X, Z> transformValues(SortedMap<? extends X, ? extends Y> input, Function<Y, Z> function)
What is the way to do that with java 8?