V
- the value typepublic class LinkedCaseInsensitiveMap<V>
extends java.lang.Object
implements java.util.Map<java.lang.String,V>, java.io.Serializable, java.lang.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.
Constructor and 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 a
LinkedHashMap
with the given initial capacity and stores case-insensitive keys
according to the default Locale (by default in lower case). |
LinkedCaseInsensitiveMap(int initialCapacity,
java.util.Locale locale)
Create a new LinkedCaseInsensitiveMap that wraps a
LinkedHashMap
with the given initial capacity and stores case-insensitive keys
according to the given Locale (by default in lower case). |
LinkedCaseInsensitiveMap(java.util.Locale locale)
Create a new LinkedCaseInsensitiveMap that stores case-insensitive keys
according to the given Locale (by default in lower case).
|
Modifier and Type | Method and Description |
---|---|
void |
clear() |
LinkedCaseInsensitiveMap<V> |
clone() |
V |
computeIfAbsent(java.lang.String key,
java.util.function.Function<? super java.lang.String,? extends V> mappingFunction) |
boolean |
containsKey(java.lang.Object key) |
boolean |
containsValue(java.lang.Object value) |
protected java.lang.String |
convertKey(java.lang.String key)
Convert the given key to a case-insensitive key.
|
java.util.Set<java.util.Map.Entry<java.lang.String,V>> |
entrySet() |
boolean |
equals(java.lang.Object obj) |
V |
get(java.lang.Object key) |
java.util.Locale |
getLocale()
Return the locale used by this
LinkedCaseInsensitiveMap . |
V |
getOrDefault(java.lang.Object key,
V defaultValue) |
int |
hashCode() |
boolean |
isEmpty() |
java.util.Set<java.lang.String> |
keySet() |
V |
put(java.lang.String key,
V value) |
void |
putAll(java.util.Map<? extends java.lang.String,? extends V> map) |
V |
putIfAbsent(java.lang.String key,
V value) |
V |
remove(java.lang.Object key) |
protected boolean |
removeEldestEntry(java.util.Map.Entry<java.lang.String,V> eldest)
Determine whether this map should remove the given eldest entry.
|
int |
size() |
java.lang.String |
toString() |
java.util.Collection<V> |
values() |
public LinkedCaseInsensitiveMap()
convertKey(String)
public LinkedCaseInsensitiveMap(@Nullable java.util.Locale locale)
locale
- the Locale to use for case-insensitive key conversionconvertKey(String)
public LinkedCaseInsensitiveMap(int initialCapacity)
LinkedHashMap
with the given initial capacity and stores case-insensitive keys
according to the default Locale (by default in lower case).initialCapacity
- the initial capacityconvertKey(String)
public LinkedCaseInsensitiveMap(int initialCapacity, @Nullable java.util.Locale locale)
LinkedHashMap
with the given initial capacity and stores case-insensitive keys
according to the given Locale (by default in lower case).initialCapacity
- the initial capacitylocale
- the Locale to use for case-insensitive key conversionconvertKey(String)
public int size()
size
in interface java.util.Map<java.lang.String,V>
public boolean isEmpty()
isEmpty
in interface java.util.Map<java.lang.String,V>
public boolean containsKey(java.lang.Object key)
containsKey
in interface java.util.Map<java.lang.String,V>
public boolean containsValue(java.lang.Object value)
containsValue
in interface java.util.Map<java.lang.String,V>
@Nullable public V get(java.lang.Object key)
get
in interface java.util.Map<java.lang.String,V>
@Nullable public V getOrDefault(java.lang.Object key, V defaultValue)
getOrDefault
in interface java.util.Map<java.lang.String,V>
@Nullable public V put(java.lang.String key, @Nullable V value)
put
in interface java.util.Map<java.lang.String,V>
public void putAll(java.util.Map<? extends java.lang.String,? extends V> map)
putAll
in interface java.util.Map<java.lang.String,V>
@Nullable public V putIfAbsent(java.lang.String key, @Nullable V value)
putIfAbsent
in interface java.util.Map<java.lang.String,V>
@Nullable public V computeIfAbsent(java.lang.String key, java.util.function.Function<? super java.lang.String,? extends V> mappingFunction)
computeIfAbsent
in interface java.util.Map<java.lang.String,V>
@Nullable public V remove(java.lang.Object key)
remove
in interface java.util.Map<java.lang.String,V>
public void clear()
clear
in interface java.util.Map<java.lang.String,V>
public java.util.Set<java.lang.String> keySet()
keySet
in interface java.util.Map<java.lang.String,V>
public java.util.Collection<V> values()
values
in interface java.util.Map<java.lang.String,V>
public java.util.Set<java.util.Map.Entry<java.lang.String,V>> entrySet()
entrySet
in interface java.util.Map<java.lang.String,V>
public LinkedCaseInsensitiveMap<V> clone()
clone
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in interface java.util.Map<java.lang.String,V>
equals
in class java.lang.Object
public int hashCode()
hashCode
in interface java.util.Map<java.lang.String,V>
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public java.util.Locale getLocale()
LinkedCaseInsensitiveMap
.
Used for case-insensitive key conversion.LinkedCaseInsensitiveMap(Locale)
,
convertKey(String)
protected java.lang.String convertKey(java.lang.String key)
The default implementation converts the key to lower-case according to this Map's Locale.
key
- the user-specified keyString.toLowerCase(Locale)
protected boolean removeEldestEntry(java.util.Map.Entry<java.lang.String,V> eldest)
eldest
- the candidate entrytrue
for removing it, false
for keeping itLinkedHashMap.removeEldestEntry(java.util.Map.Entry<K, V>)