Package com.foxinmy.weixin4j.util
Class LinkedCaseInsensitiveMap<V>
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap<K,V>
-
- java.util.LinkedHashMap<String,V>
-
- com.foxinmy.weixin4j.util.LinkedCaseInsensitiveMap<V>
-
- All Implemented Interfaces:
Serializable,Cloneable,Map<String,V>
public class LinkedCaseInsensitiveMap<V> extends LinkedHashMap<String,V>
LinkedHashMapvariant that stores String keys in a case-insensitive manner, for example for key-based access in a results table.Preserves the original order as well as the original casing of keys, while allowing for contains, get and remove calls with any case of key.
Does not support
nullkeys.- Since:
- 3.0
- Author:
- Juergen Hoeller
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object,V extends Object>
-
-
Constructor Summary
Constructors Constructor Description LinkedCaseInsensitiveMap()Create a new LinkedCaseInsensitiveMap for the default Locale.LinkedCaseInsensitiveMap(int initialCapacity)Create a new LinkedCaseInsensitiveMap that wraps aLinkedHashMapwith the given initial capacity and stores lower-case keys according to the default Locale.LinkedCaseInsensitiveMap(int initialCapacity, Locale locale)Create a new LinkedCaseInsensitiveMap that wraps aLinkedHashMapwith the given initial capacity and stores lower-case keys according to the given Locale.LinkedCaseInsensitiveMap(Locale locale)Create a new LinkedCaseInsensitiveMap that stores lower-case keys according to the given Locale.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()booleancontainsKey(Object key)protected StringconvertKey(String key)Convert the given key to a case-insensitive key.Vget(Object key)Vput(String key, V value)voidputAll(Map<? extends String,? extends V> map)Vremove(Object key)-
Methods inherited from class java.util.LinkedHashMap
containsValue, entrySet, forEach, getOrDefault, keySet, removeEldestEntry, replaceAll, values
-
Methods inherited from class java.util.HashMap
clone, compute, computeIfAbsent, computeIfPresent, isEmpty, merge, putIfAbsent, remove, replace, replace, size
-
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, hashCode, isEmpty, merge, putIfAbsent, remove, replace, replace, size
-
-
-
-
Constructor Detail
-
LinkedCaseInsensitiveMap
public LinkedCaseInsensitiveMap()
Create a new LinkedCaseInsensitiveMap for the default Locale.- See Also:
String.toLowerCase()
-
LinkedCaseInsensitiveMap
public LinkedCaseInsensitiveMap(Locale locale)
Create a new LinkedCaseInsensitiveMap that stores lower-case keys according to the given Locale.- Parameters:
locale- the Locale to use for lower-case conversion- See Also:
String.toLowerCase(java.util.Locale)
-
LinkedCaseInsensitiveMap
public LinkedCaseInsensitiveMap(int initialCapacity)
Create a new LinkedCaseInsensitiveMap that wraps aLinkedHashMapwith the given initial capacity and stores lower-case keys according to the default Locale.- Parameters:
initialCapacity- the initial capacity- See Also:
String.toLowerCase()
-
LinkedCaseInsensitiveMap
public LinkedCaseInsensitiveMap(int initialCapacity, Locale locale)Create a new LinkedCaseInsensitiveMap that wraps aLinkedHashMapwith the given initial capacity and stores lower-case keys according to the given Locale.- Parameters:
initialCapacity- the initial capacitylocale- the Locale to use for lower-case conversion- See Also:
String.toLowerCase(java.util.Locale)
-
-
Method Detail
-
containsKey
public boolean containsKey(Object key)
- Specified by:
containsKeyin interfaceMap<String,V>- Overrides:
containsKeyin classHashMap<String,V>
-
clear
public void clear()
-
convertKey
protected String convertKey(String key)
Convert the given key to a case-insensitive key.The default implementation converts the key to lower-case according to this Map's Locale.
- Parameters:
key- the user-specified key- Returns:
- the key to use for storing
- See Also:
String.toLowerCase(java.util.Locale)
-
-