Java Map Replace replaceValuesToSynonyms(Map dic, Map synonims)

Here you can find the source of replaceValuesToSynonyms(Map dic, Map synonims)

Description

replace Values To Synonyms

License

LGPL

Declaration

public static <K, V> Map<K, V> replaceValuesToSynonyms(Map<K, V> dic, Map<V, V> synonims) 

Method Source Code

//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;
    }
}

Related

  1. replaceString(String uri, String baseURI, Map prefixes)
  2. replaceTemplates(String template, Map entries)
  3. replaceTokens(String inputString, Map tokenMap)
  4. replaceToStringBuilder(String s, String begin, String end, Map values)
  5. replaceValues(String s, String begin, String end, Map values)
  6. replaceVariable(final String src, final Map value)
  7. replaceVariables(String chart, Map variables)
  8. replaceVars(String origString, Map vars)
  9. replaceVars(String s, Map m)