Here you can find the source of reverseMap(Map
Parameter | Description |
---|---|
gruleTypeMapping | a parameter |
public static <K, V> Map<V, K> reverseMap(Map<K, V> map)
//package com.java2s; /******************************************************************************* * Copyright (c) 2012 pf_miles.//from w w w .jav a2 s . c o m * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * pf_miles - initial API and implementation ******************************************************************************/ import java.util.HashMap; import java.util.Map; public class Main { /** * 'reverse' a map's key and values, beware this may cause losing some * entries(values may have duplications) * * @param gruleTypeMapping * @return */ public static <K, V> Map<V, K> reverseMap(Map<K, V> map) { Map<V, K> ret = new HashMap<V, K>(); for (Map.Entry<K, V> e : map.entrySet()) { ret.put(e.getValue(), e.getKey()); } return ret; } }