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

cn.jiangzeyin.util.KeyMap Maven / Gradle / Ivy

There is a newer version: 1.2.11
Show newest version
package cn.jiangzeyin.util;

import java.util.*;

/**
 * 不区分大小写
 * Created by jiangzeyin on 2017/8/15.
 *
 * @author jiangzeyin
 */
public class KeyMap {
    private Map map;

    public KeyMap(Map map) {
        Objects.requireNonNull(map);
        this.map = map;
        Set> entries = this.map.entrySet();
        Iterator> iterator = entries.iterator();
        Map temp = new HashMap<>();
        while (iterator.hasNext()) {
            Map.Entry entry = iterator.next();
            String key = entry.getKey().toString();
            String newKey = key.toLowerCase();
            temp.put((K) newKey, entry.getValue());
            iterator.remove();
        }
        this.map.clear();
        this.map.putAll(temp);
    }

    public V get(K k) {
        return map.get(k);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy