Top Description Inners Fields Constructors Methods
org.springframework.util

public Class LinkedCaseInsensitiveMap<V>

extends Object
implements Map<String, V>, Serializable, Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable, java.io.Serializable, java.util.Map
Annotations
@SuppressWarnings:serial
Type Parameters
<V>
the value type
Imports
java.io.Serializable, java.util.AbstractCollection, .AbstractSet, .Collection, .HashMap, .Iterator, .LinkedHashMap, .Locale, .Map, .Set, .Spliterator, java.util.function.BiConsumer, .Consumer, .Function, org.springframework.lang.Nullable

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.

Authors
Juergen Hoeller, Phillip Webb
Since
3.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private abstract class
private class
private class
private class
private class
private class
private class

Field Summary

Modifier and TypeField and Description
private final HashMap<String, String>
private transient volatile Set<Map.Entry<String, V>>
private transient volatile Set<String>
private final Locale
private final LinkedHashMap<String, V>
private transient volatile Collection<V>

Constructor Summary

AccessConstructor and Description
public
LinkedCaseInsensitiveMap()

Create a new LinkedCaseInsensitiveMap that stores case-insensitive keys according to the default Locale (by default in lower case).

public
LinkedCaseInsensitiveMap(Locale
the Locale to use for case-insensitive key conversion
locale
)

Create a new LinkedCaseInsensitiveMap that stores case-insensitive keys according to the given Locale (in lower case).

public
LinkedCaseInsensitiveMap(int
the expected number of elements (with a corresponding capacity to be derived so that no resize/rehash operations are needed)
expectedSize
)

Create a new LinkedCaseInsensitiveMap that wraps a LinkedHashMap with 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).

public
LinkedCaseInsensitiveMap(int
the expected number of elements (with a corresponding capacity to be derived so that no resize/rehash operations are needed)
expectedSize
,
Locale
the Locale to use for case-insensitive key conversion
locale
)

Create a new LinkedCaseInsensitiveMap that wraps a LinkedHashMap with 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).

private

Method Summary

Modifier and TypeMethod and Description
public void
clear()

Implements java.util.Map.clear.

Removes all of the mappings from this map (optional operation).
public LinkedCaseInsensitiveMap<V>
clone()

Overrides java.lang.Object.clone.

Creates and returns a copy of this object.
public V
computeIfAbsent(String
key with which the specified value is to be associated
key
,
Function<? super String, ? extends V>
the mapping function to compute a value
mappingFunction
)

Overrides default java.util.Map.computeIfAbsent.

If the specified key is not already associated with a value (or is mapped to null), attempts to compute its value using the given mapping function and enters it into this map unless null.
public boolean
containsKey(Object
key whose presence in this map is to be tested
key
)

Implements java.util.Map.containsKey.

Returns true if this map contains a mapping for the specified key.
public boolean
containsValue(Object
value whose presence in this map is to be tested
value
)

Implements java.util.Map.containsValue.

Returns true if this map maps one or more keys to the specified value.
protected String

Returns:

the key to use for storing
convertKey
(String
the user-specified key
key
)

Convert the given key to a case-insensitive key.

public Set<Map.Entry<String, V>>
entrySet()

Implements java.util.Map.entrySet.

Returns a Set view of the mappings contained in this map.
public boolean
equals(Object
object to be compared for equality with this map
other
)

Overrides java.lang.Object.equals.

Implements java.util.Map.equals.

Compares the specified object with this map for equality.
public void
forEach(BiConsumer<? super String, ? super V>
The action to be performed for each entry
action
)

Overrides default java.util.Map.forEach.

Performs the given action for each entry in this map until all entries have been processed or the action throws an exception.
public V
get(Object
the key whose associated value is to be returned
key
)

Implements java.util.Map.get.

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.
public Locale
getLocale()

Return the locale used by this LinkedCaseInsensitiveMap.

public V
getOrDefault(Object
the key whose associated value is to be returned
key
,
V
the default mapping of the key
defaultValue
)

Overrides default java.util.Map.getOrDefault.

Returns the value to which the specified key is mapped, or defaultValue if this map contains no mapping for the key.
public int
hashCode()

Overrides java.lang.Object.hashCode.

Implements java.util.Map.hashCode.

Returns the hash code value for this map.
public boolean
isEmpty()

Implements java.util.Map.isEmpty.

Returns true if this map contains no key-value mappings.
public Set<String>
keySet()

Implements java.util.Map.keySet.

Returns a Set view of the keys contained in this map.
public V
put(String
key with which the specified value is to be associated
key
,
V
value to be associated with the specified key
value
)

Implements java.util.Map.put.

Associates the specified value with the specified key in this map (optional operation).
public void
putAll(Map<? extends String, ? extends V>
mappings to be stored in this map
map
)

Implements java.util.Map.putAll.

Copies all of the mappings from the specified map to this map (optional operation).
public V
putIfAbsent(String
key with which the specified value is to be associated
key
,
V
value to be associated with the specified key
value
)

Overrides default java.util.Map.putIfAbsent.

If the specified key is not already associated with a value (or is mapped to null) associates it with the given value and returns null, else returns the current value.
public V
remove(Object
key whose mapping is to be removed from the map
key
)

Implements java.util.Map.remove.

Removes the mapping for a key from this map if it is present (optional operation).
private String
protected boolean

Returns:

true for removing it, false for keeping it
removeEldestEntry
(Map.Entry<String, V>
the candidate entry
eldest
)

Determine whether this map should remove the given eldest entry.

public int
size()

Implements java.util.Map.size.

Returns the number of key-value mappings in this map.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public Collection<V>
values()

Implements java.util.Map.values.

Returns a Collection view of the values contained in this map.
Inherited from java.lang.Object:
finalizegetClassnotifynotifyAllwaitwaitwait