V - the value typepublic 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.
| 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,
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(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(String key,
Function<? super String,? extends V> mappingFunction) |
boolean |
containsKey(Object key) |
boolean |
containsValue(Object value) |
protected String |
convertKey(String key)
Convert the given key to a case-insensitive key.
|
Set<Map.Entry<String,V>> |
entrySet() |
boolean |
equals(Object other) |
V |
get(Object key) |
Locale |
getLocale()
Return the locale used by this
LinkedCaseInsensitiveMap. |
V |
getOrDefault(Object key,
V defaultValue) |
int |
hashCode() |
boolean |
isEmpty() |
Set<String> |
keySet() |
V |
put(String key,
V value) |
void |
putAll(Map<? extends String,? extends V> map) |
V |
putIfAbsent(String key,
V value) |
V |
remove(Object key) |
protected boolean |
removeEldestEntry(Map.Entry<String,V> eldest)
Determine whether this map should remove the given eldest entry.
|
int |
size() |
String |
toString() |
Collection<V> |
values() |
public LinkedCaseInsensitiveMap()
convertKey(String)public LinkedCaseInsensitiveMap(@Nullable 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
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 Map<String,V>public boolean isEmpty()
isEmpty in interface Map<String,V>public boolean containsKey(Object key)
containsKey in interface Map<String,V>public boolean containsValue(Object value)
containsValue in interface Map<String,V>@Nullable public V getOrDefault(Object key, V defaultValue)
getOrDefault in interface Map<String,V>@Nullable public V put(String key, @Nullable V value)
put in interface Map<String,V>public void putAll(Map<? extends String,? extends V> map)
putAll in interface Map<String,V>@Nullable public V putIfAbsent(String key, @Nullable V value)
putIfAbsent in interface Map<String,V>@Nullable public V computeIfAbsent(String key, Function<? super String,? extends V> mappingFunction)
computeIfAbsent in interface Map<String,V>public void clear()
clear in interface Map<String,V>public Set<String> keySet()
keySet in interface Map<String,V>public Set<Map.Entry<String,V>> entrySet()
entrySet in interface Map<String,V>public LinkedCaseInsensitiveMap<V> clone()
clone in class Objectpublic boolean equals(@Nullable Object other)
equals in interface Map<String,V>equals in class Objectpublic int hashCode()
hashCode in interface Map<String,V>hashCode in class Objectpublic String toString()
toString in class Objectpublic Locale getLocale()
LinkedCaseInsensitiveMap.
Used for case-insensitive key conversion.LinkedCaseInsensitiveMap(Locale),
convertKey(String)protected String convertKey(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(Map.Entry<String,V> eldest)
eldest - the candidate entrytrue for removing it, false for keeping itLinkedHashMap.removeEldestEntry(java.util.Map.Entry<K, V>)Copyright © 2010-2020 Toolsverse. All Rights Reserved.