Here you can find the source of reverseMap(Map
public static <K, G> Map<K, G> reverseMap(Map<String, K> keyIdMap, Map<String, G> keyValueMap)
//package com.java2s; import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; public class Main { public static <K, G> Map<K, G> reverseMap(Map<String, K> keyIdMap, Map<String, G> keyValueMap) { Map<K, G> ret = new HashMap<K, G>(); for (Entry<String, G> entry : keyValueMap.entrySet()) { K id = keyIdMap.get(entry.getKey()); ret.put(id, entry.getValue()); }//from w w w . ja va 2 s . c o m return ret; } }