Package org.springframework.util
Class LinkedCaseInsensitiveMap<V>
- java.lang.Object
- org.springframework.util.LinkedCaseInsensitiveMap<V>
- Type Parameters:
V- the value type
- All Implemented Interfaces:
Serializable,Cloneable,Map<String,V>
public class LinkedCaseInsensitiveMap<V> extends Object implements Map<String,V>, Serializable, Cloneable
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
Constructor Summary
Constructors Constructor Description LinkedCaseInsensitiveMap()Create a new LinkedCaseInsensitiveMap that stores case-insensitive keys according to the default Locale (by default in lower case).LinkedCaseInsensitiveMap(int initialCapacity)Create a new LinkedCaseInsensitiveMap that wraps aLinkedHashMapwith the given initial capacity and stores case-insensitive keys according to the default Locale (by default in lower case).LinkedCaseInsensitiveMap(int initialCapacity, Locale locale)Create a new LinkedCaseInsensitiveMap that wraps aLinkedHashMapwith the given initial capacity and stores case-insensitive keys according to the given Locale (by default in lower case).LinkedCaseInsensitiveMap(Locale locale)Create a new LinkedCaseInsensitiveMap that stores case-insensitive keys according to the given Locale (by default in lower case).
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()LinkedCaseInsensitiveMap<V>clone()booleancontainsKey(Object key)booleancontainsValue(Object value)protected StringconvertKey(String key)Convert the given key to a case-insensitive key.Set<Map.Entry<String,V>>entrySet()booleanequals(Object other)Vget(Object key)LocalegetLocale()Return the locale used by thisLinkedCaseInsensitiveMap.VgetOrDefault(Object key, V defaultValue)inthashCode()booleanisEmpty()Set<String>keySet()Vput(String key, V value)voidputAll(Map<? extends String,? extends V> map)Vremove(Object key)protected booleanremoveEldestEntry(Map.Entry<String,V> eldest)Determine whether this map should remove the given eldest entry.intsize()StringtoString()Collection<V>values()Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, merge, putIfAbsent, remove, replace, replace, replaceAll
Constructor Detail
LinkedCaseInsensitiveMap
public LinkedCaseInsensitiveMap()
Create a new LinkedCaseInsensitiveMap that stores case-insensitive keys according to the default Locale (by default in lower case).- See Also:
convertKey(String)
LinkedCaseInsensitiveMap
public LinkedCaseInsensitiveMap(Locale locale)
Create a new LinkedCaseInsensitiveMap that stores case-insensitive keys according to the given Locale (by default in lower case).- Parameters:
locale- the Locale to use for case-insensitive key conversion- See Also:
convertKey(String)
LinkedCaseInsensitiveMap
public LinkedCaseInsensitiveMap(int initialCapacity)
Create a new LinkedCaseInsensitiveMap that wraps aLinkedHashMapwith the given initial capacity and stores case-insensitive keys according to the default Locale (by default in lower case).- Parameters:
initialCapacity- the initial capacity- See Also:
convertKey(String)
LinkedCaseInsensitiveMap
public LinkedCaseInsensitiveMap(int initialCapacity, Locale locale)
Create a new LinkedCaseInsensitiveMap that wraps aLinkedHashMapwith the given initial capacity and stores case-insensitive keys according to the given Locale (by default in lower case).- Parameters:
initialCapacity- the initial capacitylocale- the Locale to use for case-insensitive key conversion- See Also:
convertKey(String)
Method Detail
containsKey
public boolean containsKey(Object key)
- Specified by:
containsKeyin interfaceMap<String,V>
containsValue
public boolean containsValue(Object value)
- Specified by:
containsValuein interfaceMap<String,V>
getOrDefault
public V getOrDefault(Object key, V defaultValue)
- Specified by:
getOrDefaultin interfaceMap<String,V>
clone
public LinkedCaseInsensitiveMap<V> clone()
hashCode
public int hashCode()
getLocale
public Locale getLocale()
Return the locale used by thisLinkedCaseInsensitiveMap. Used for case-insensitive key conversion.- Since:
- 4.3.10
- See Also:
LinkedCaseInsensitiveMap(Locale),convertKey(String)
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(Locale)
removeEldestEntry
protected boolean removeEldestEntry(Map.Entry<String,V> eldest)
Determine whether this map should remove the given eldest entry.- Parameters:
eldest- the candidate entry- Returns:
truefor removing it,falsefor keeping it- See Also:
LinkedHashMap.removeEldestEntry(java.util.Map.Entry<K, V>)