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

com.greenhat.util.MapUtil Maven / Gradle / Ivy

There is a newer version: 1.2
Show newest version
package com.greenhat.util;

import org.apache.commons.collections.MapUtils;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * 映射操作工具类
 *
 * @author huangyong
 * @since 1.0
 */
public class MapUtil {

    /**
     * 判断 Map 是否非空
     */
    public static boolean isNotEmpty(Map map) {
        return MapUtils.isNotEmpty(map);
    }

    /**
     * 判断 Map 是否为空
     */
    public static boolean isEmpty(Map map) {
        return MapUtils.isEmpty(map);
    }

    /**
     * 转置 Map
     */
    public static  Map invert(Map source) {
        Map target = null;
        if (isNotEmpty(source)) {
            target = new LinkedHashMap(source.size());
            for (Map.Entry entry : source.entrySet()) {
                target.put(entry.getValue(), entry.getKey());
            }
        }
        return target;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy