You can match your records with a new intermediate record with a derived key, and then pass a pair of values doCalculation():
myValues.entrySet()
.stream()
.map(e -> new SimpleEntry<>(getActualKey(e.getKey()), e.getValue()))
.collect(Collectors.toMap(e -> e.getKey(), e -> doCalculation(e.getKey(), e.getValue())));
source
share