cn.hutool.core.map.CaseInsensitiveTreeMap Maven / Gradle / Ivy
package cn.hutool.core.map;
import java.util.Comparator;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;
/**
* 忽略大小写的{@link TreeMap}
* 对KEY忽略大小写,get("Value")和get("value")获得的值相同,put进入的值也会被覆盖
*
* @author Looly
*
* @param 键类型
* @param 值类型
* @since 3.3.1
*/
public class CaseInsensitiveTreeMap extends CaseInsensitiveMap {
private static final long serialVersionUID = 4043263744224569870L;
// ------------------------------------------------------------------------- Constructor start
/**
* 构造
*/
public CaseInsensitiveTreeMap() {
this((Comparator super K>) null);
}
/**
* 构造
*
* @param m Map
* @since 3.1.2
*/
public CaseInsensitiveTreeMap(Map extends K, ? extends V> m) {
this();
this.putAll(m);
}
/**
* 构造
*
* @param m Map,初始Map,键值对会被复制到新的TreeMap中
* @since 3.1.2
*/
public CaseInsensitiveTreeMap(SortedMap extends K, ? extends V> m) {
super(MapBuilder.create(new TreeMap(m)));
}
/**
* 构造
*
* @param comparator 比较器,{@code null}表示使用默认比较器
*/
public CaseInsensitiveTreeMap(Comparator super K> comparator) {
super(MapBuilder.create(new TreeMap<>(comparator)));
}
// ------------------------------------------------------------------------- Constructor end
}