All Downloads are FREE. Search and download functionalities are using the official Maven repository.

top.lingyuzhao.utils.ClassUtils Maven / Gradle / Ivy

The newest version!
package top.lingyuzhao.utils;

import java.util.HashMap;
import java.util.Map;

/**
 * 类工具包
 *
 * @author zhao
 */
public final class ClassUtils {

    /**
     * 反转一个 map 中的所有 kv
     *
     * @param map 需要被反转的map
     * @param  结果的 key类型
     * @param  结果的 value 类型
     * @return HashMap K=key, V=value
     */
    public static  HashMap KV_reverse(Map map) {
        HashMap hashMap = new HashMap<>(map.size());
        for (Map.Entry entry : map.entrySet()) {
            hashMap.put(entry.getValue(), entry.getKey());
        }
        return hashMap;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy