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 
LinkedHashMap variant 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 null keys.
- Since:
- 3.0
- Author:
- Juergen Hoeller, Phillip Webb
- See Also:
- 
Nested Class Summary
- 
Constructor SummaryConstructorsConstructorDescriptionCreate a new LinkedCaseInsensitiveMap that stores case-insensitive keys according to the default Locale (by default in lower case).LinkedCaseInsensitiveMap(int expectedSize) Create a new LinkedCaseInsensitiveMap that wraps aLinkedHashMapwith an initial capacity that can accommodate the specified number of elements without any immediate resize/rehash operations to be expected, storing case-insensitive keys according to the default Locale (in lower case).LinkedCaseInsensitiveMap(int expectedSize, Locale locale) Create a new LinkedCaseInsensitiveMap that wraps aLinkedHashMapwith an initial capacity that can accommodate the specified number of elements without any immediate resize/rehash operations to be expected, storing case-insensitive keys according to the given Locale (in lower case).LinkedCaseInsensitiveMap(Locale locale) Create a new LinkedCaseInsensitiveMap that stores case-insensitive keys according to the given Locale (in lower case).
- 
Method SummaryModifier and TypeMethodDescriptionvoidclear()clone()computeIfAbsent(String key, Function<? super String, ? extends V> mappingFunction) booleancontainsKey(Object key) booleancontainsValue(Object value) protected StringconvertKey(String key) Convert the given key to a case-insensitive key.entrySet()booleanReturn the locale used by thisLinkedCaseInsensitiveMap.getOrDefault(Object key, V defaultValue) inthashCode()booleanisEmpty()keySet()voidputIfAbsent(String key, V value) protected booleanremoveEldestEntry(Map.Entry<String, V> eldest) Determine whether this map should remove the given eldest entry.intsize()toString()values()Methods inherited from class java.lang.Objectfinalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Mapcompute, computeIfPresent, forEach, merge, remove, replace, replace, replaceAll
- 
Constructor Details- 
LinkedCaseInsensitiveMappublic LinkedCaseInsensitiveMap()Create a new LinkedCaseInsensitiveMap that stores case-insensitive keys according to the default Locale (by default in lower case).- See Also:
 
- 
LinkedCaseInsensitiveMapCreate a new LinkedCaseInsensitiveMap that stores case-insensitive keys according to the given Locale (in lower case).- Parameters:
- locale- the Locale to use for case-insensitive key conversion
- See Also:
 
- 
LinkedCaseInsensitiveMappublic LinkedCaseInsensitiveMap(int expectedSize) Create a new LinkedCaseInsensitiveMap that wraps aLinkedHashMapwith an initial capacity that can accommodate the specified number of elements without any immediate resize/rehash operations to be expected, storing case-insensitive keys according to the default Locale (in lower case).- Parameters:
- expectedSize- the expected number of elements (with a corresponding capacity to be derived so that no resize/rehash operations are needed)
- See Also:
 
- 
LinkedCaseInsensitiveMapCreate a new LinkedCaseInsensitiveMap that wraps aLinkedHashMapwith an initial capacity that can accommodate the specified number of elements without any immediate resize/rehash operations to be expected, storing case-insensitive keys according to the given Locale (in lower case).- Parameters:
- expectedSize- the expected number of elements (with a corresponding capacity to be derived so that no resize/rehash operations are needed)
- locale- the Locale to use for case-insensitive key conversion
- See Also:
 
 
- 
- 
Method Details- 
sizepublic int size()
- 
isEmptypublic boolean isEmpty()
- 
containsKey- Specified by:
- containsKeyin interface- Map<String,- V> 
 
- 
containsValue- Specified by:
- containsValuein interface- Map<String,- V> 
 
- 
get
- 
getOrDefault- Specified by:
- getOrDefaultin interface- Map<String,- V> 
 
- 
put
- 
putAll
- 
putIfAbsent- Specified by:
- putIfAbsentin interface- Map<String,- V> 
 
- 
computeIfAbsent@Nullable public V computeIfAbsent(String key, Function<? super String, ? extends V> mappingFunction) - Specified by:
- computeIfAbsentin interface- Map<String,- V> 
 
- 
remove
- 
clearpublic void clear()
- 
keySet
- 
values
- 
entrySet
- 
clone
- 
equals
- 
hashCodepublic int hashCode()
- 
toString
- 
getLocaleReturn the locale used by thisLinkedCaseInsensitiveMap. Used for case-insensitive key conversion.- Since:
- 4.3.10
- See Also:
 
- 
convertKeyConvert 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:
 
- 
removeEldestEntryDetermine whether this map should remove the given eldest entry.- Parameters:
- eldest- the candidate entry
- Returns:
- truefor removing it,- falsefor keeping it
- See Also:
 
 
-