UTIL_Map.CaseInsensitiveMap
Class
global inherited sharing class UTIL_Map.CaseInsensitiveMapA Map implementation that performs case-insensitive key lookups. Keys are normalised to lower case for internal storage and retrieval, but the original casing is retained for display and export operations.
Example
UTIL_Map.CaseInsensitiveMap ciMap = new UTIL_Map.CaseInsensitiveMap();
ciMap.put('Acme Ltd', myAccount);
Account a = (Account) ciMap.get('ACME LTD');Methods
| Method | Description |
|---|---|
| global void clear() | Empties this map, discarding all stored entries. |
| global Boolean containsKey(String key) | Checks whether this map holds an entry for the specified key, ignoring letter case. |
| global UTIL_Map.CaseInsensitiveMap copy() | Produces a shallow copy of this CaseInsensitiveMap. |
| global Object get(String key) | Retrieves the value mapped to the supplied key using a case-insensitive comparison. |
| global Boolean isEmpty() | Indicates whether this map is empty, containing zero entries. |
| global Set<String> keySet() | Returns the set of keys in their original, caller-supplied casing. |
| global void put(String key, Object value) | Stores a value under the given key. |
| global void putAll(Map<String, Object> sourceMap) | Inserts all entries from the supplied map into this map. |
| global Object remove(String key) | Deletes the entry for the given key (case-insensitive match) and returns the previously associated value. |
| global Integer size() | Returns the current number of key-value mappings stored in this map. |
| global Map<String, Object> toMap() | Exports the contents of this map to a standard Map, restoring the original key casing. |
| global List<Object> values() | Returns all values stored in this map as an ordered list. |
clear
global void clear()Empties this map, discarding all stored entries.
Example
instance.clear();containsKey
global Boolean containsKey(String key)Checks whether this map holds an entry for the specified key, ignoring letter case.
Parameters
| Parameter | Type | Description |
|---|---|---|
key | String | The key whose presence in this map is to be tested. |
Returns Boolean — Boolean true if this map contains a mapping for the specified key, otherwise false.
Example
Boolean result = instance.containsKey('value');copy
global UTIL_Map.CaseInsensitiveMap copy()Produces a shallow copy of this CaseInsensitiveMap. The returned instance is independent; mutations do not propagate between the original and the copy.
Returns UTIL_Map.CaseInsensitiveMap — A new CaseInsensitiveMap instance that is a copy of this one.
Example
CaseInsensitiveMap result = instance.copy();get
global Object get(String key)Retrieves the value mapped to the supplied key using a case-insensitive comparison. Returns null when no mapping exists.
Parameters
| Parameter | Type | Description |
|---|---|---|
key | String | The key whose associated value is to be returned. |
Returns Object — The value associated with the key, or null if no mapping exists.
Example
Object result = instance.get('value');isEmpty
global Boolean isEmpty()Indicates whether this map is empty, containing zero entries.
Returns Boolean — Boolean true if the map is empty, otherwise false.
Example
Boolean result = instance.isEmpty();keySet
global Set<String> keySet()Returns the set of keys in their original, caller-supplied casing.
Returns String — A Set of the original keys in the map.
Example
Set<String> result = instance.keySet();put
global void put(String key, Object value)Stores a value under the given key. If a mapping already exists for the same key (regardless of letter case), it is replaced.
Parameters
| Parameter | Type | Description |
|---|---|---|
key | String | The key with which the specified value is to be associated. |
value | Object | The value to be associated with the specified key. |
Example
instance.put('value', 'value');putAll
global void putAll(Map<String, Object> sourceMap)Inserts all entries from the supplied map into this map. Existing mappings whose keys match (case-insensitively) are overwritten.
Parameters
| Parameter | Type | Description |
|---|---|---|
sourceMap | Map | The map whose entries are to be placed into this map. |
Example
instance.putAll(new Map<String, Object>{'key' => 'value'});remove
global Object remove(String key)Deletes the entry for the given key (case-insensitive match) and returns the previously associated value.
Parameters
| Parameter | Type | Description |
|---|---|---|
key | String | The key whose mapping is to be removed from the map. |
Returns Object — The previous value associated with the key, or null if there was no mapping for the key.
Example
Object result = instance.remove('value');size
global Integer size()Returns the current number of key-value mappings stored in this map.
Returns Integer — The number of entries in the map.
Example
Integer result = instance.size();toMap
global Map<String, Object> toMap()Exports the contents of this map to a standard Map , restoring the original key casing.
Returns Object — A new Map<String, Object> containing all entries from this map.
Example
Map<String, Object> result = instance.toMap();values
global List<Object> values()Returns all values stored in this map as an ordered list.
Returns Object — A List of the values in the map.
Example
List<Object> result = instance.values();Constructors
| Constructor | Description |
|---|---|
| global CaseInsensitiveMap() | Constructs an empty CaseInsensitiveMap. |
| global CaseInsensitiveMap(Map<String, Object> sourceMap) | Constructs a new CaseInsensitiveMap pre-populated with entries from the provided standard map. |
CaseInsensitiveMap()
global CaseInsensitiveMap()Constructs an empty CaseInsensitiveMap.
Example
UTIL_Map.CaseInsensitiveMap instance = new UTIL_Map.CaseInsensitiveMap();CaseInsensitiveMap(Map<String, Object> sourceMap)
global CaseInsensitiveMap(Map<String, Object> sourceMap)Constructs a new CaseInsensitiveMap pre-populated with entries from the provided standard map.
Parameters
| Parameter | Type | Description |
|---|---|---|
sourceMap | Map | The map whose entries are to be placed into this map. |
Example
UTIL_Map.CaseInsensitiveMap instance = new UTIL_Map.CaseInsensitiveMap(new Map<String, Object>{'key' => 'value'});