LinkedCaseInsensitiveMap

LinkedCaseInsensitiveMap<V> implements Map<String, V>, Serializable, Cloneable

key忽略大小写的LinkedMap,不支持null作为key

 

private final LinkedHashMap<String, V> targetMap;  真实的容器,key=真实key,value=存放的value

private final HashMap<String, String> caseInsensitiveKeys;  key=真实key小写后的值,value=真实key

private final Locale locale;  key转换为小写时使用的Locale -> key.toLowerCase(getLocale());

 

#public boolean containsKey(Object key)   key是String类型 且 caseInsensitiveKeys的keys中包含参数key的小写

@Nullable
#public V get(Object key)  从caseInsensitiveKey获取真实key再从targetMap获取value

@Nullable
#public V getOrDefault(Object key, V defaultValue)  获取不到则返回默认值

@Nullable
#public V put(String key, @Nullable V value)  value可以为null,返回之前的value(可能为null)

#public void putAll(Map<? extends String, ? extends V> map)  forEach使用put

@Nullable
#public V putIfAbsent(String key, @Nullable V value)  value可以为null,返回之前的value(可能为null)

@Nullable
#public V computeIfAbsent(String key, Function<? super String, ? extends V> mappingFunction)  若旧的key已存在 且 value不是null,则返回value;否则使用function创建value,put value,并return value

@Nullable
#public V remove(Object key)