Here you can find the source of replaceValuesToSynonyms(Map
public static <K, V> Map<K, V> replaceValuesToSynonyms(Map<K, V> dic, Map<V, V> synonims)
//package com.java2s; //License from project: LGPL import java.util.HashMap; import java.util.Map; public class Main { public static <K, V> Map<K, V> replaceValuesToSynonyms(Map<K, V> dic, Map<V, V> synonims) { Map<K, V> ret = new HashMap<K, V>(dic); for (K key : dic.keySet()) { V value = dic.get(key);/*from w w w . j av a 2 s.c om*/ if (synonims.containsKey(value)) ret.put(key, synonims.get(value)); } return ret; } }