I want to change the key in a hashmap. I am making a hashmap from another hashmap.
I am basically getting an id and returning a name.
So basically what I am getting is:
'BOS': 300
But I want to get:
'Boston':300
private Map<MetricName, Map<String, Integer>> getMetric(String regionId, Map<String, String> locationMap){
Map<MetricName, Map<String, Integer>> metricTargetsMap = analyzeMetaService
.getMetricTargetsForRegion(regionId);
Map<MetricName, Map<String, Integer>> metricTargetsMapModified = new HashMap<MetricName, Map<String, Integer>>();
metricTargetsMap.forEach((metricName,targetMap)-> {
HashMap<String, Integer> modifiedMap = new HashMap<String, Integer>();
targetMap.forEach((location, targetValue) -> modifiedMap.put(locationMap.get(location), targetValue));
metricTargetsMapModified.put(metricName, modifiedMap);
}
);
return metricTargetsMapModified;
}