UTIL_SObjectDescribe.FieldsMap
Class
global inherited sharing class UTIL_SObjectDescribe.FieldsMap extends UTIL_SObjectDescribe.NamespacedAttributeMapA subclass of NamespacedAttributeMap for handling field maps returned by DescribeSObjectResult.fields.getMap().
Methods
| Method | Description |
|---|---|
| global override Boolean containsKey(String name) | Checks if the map contains a key with namespace handling enabled by default. |
| global override Boolean containsKey(String name, Boolean implyNamespace) | Checks if the map contains a key with optional namespace handling. |
| global SObjectField get(String name) | Retrieves an SObjectField by name with namespace handling enabled by default. |
| global SObjectField get(String name, Boolean implyNamespace) | Retrieves an SObjectField by name with optional namespace handling. |
| global override Set<String> keySet() | Returns the key set of the map with namespace handling disabled by default. |
| global override Set<String> keySet(Boolean implyNamespace) | Returns the key set of the map with optional namespace handling. |
| global override Integer size() | Returns the number of entries in the map. |
| global List<SObjectField> values() | Returns the list of SObjectField values in the map. |
containsKey
global override Boolean containsKey(String name)Checks if the map contains a key with namespace handling enabled by default.
Parameters
| Parameter | Type | Description |
|---|---|---|
name | String | The key to check. |
Returns Boolean — true if the key exists, false otherwise.
Example
Boolean result = instance.containsKey('myName');global override Boolean containsKey(String name, Boolean implyNamespace)Checks if the map contains a key with optional namespace handling.
Parameters
| Parameter | Type | Description |
|---|---|---|
name | String | The key to check. |
implyNamespace | Boolean | Whether to handle namespace prefixes. |
Returns Boolean — true if the key exists, false otherwise.
Example
Boolean result = instance.containsKey('myName', true);get
global SObjectField get(String name)Retrieves an SObjectField by name with namespace handling enabled by default.
Parameters
| Parameter | Type | Description |
|---|---|---|
name | String | The API name of the field. |
Returns SObjectField — The SObjectField, or null if not found.
Example
UTIL_SObjectDescribe describe = UTIL_SObjectDescribe.getDescribe('Contact');
SObjectField field = describe.getFields().get('Email');
System.debug(field?.getDescribe().getLabel()); // Outputs: Emailglobal SObjectField get(String name, Boolean implyNamespace)Retrieves an SObjectField by name with optional namespace handling.
Parameters
| Parameter | Type | Description |
|---|---|---|
name | String | The API name of the field. |
implyNamespace | Boolean | Whether to handle namespace prefixes. |
Returns SObjectField — The SObjectField, or null if not found.
Example
UTIL_SObjectDescribe describe = UTIL_SObjectDescribe.getDescribe('Contact');
SObjectField field = describe.getFields().get('Account', false);
System.debug(field?.getDescribe().name); // Outputs: AccountIdkeySet
global override Set<String> keySet()Returns the key set of the map with namespace handling disabled by default.
Returns String — A set of keys in the map.
Example
Set<String> result = instance.keySet();global override Set<String> keySet(Boolean implyNamespace)Returns the key set of the map with optional namespace handling.
Parameters
| Parameter | Type | Description |
|---|---|---|
implyNamespace | Boolean | Whether to strip namespace prefixes from keys. |
Returns String — A set of keys in the map.
Example
Set<String> result = instance.keySet(true);size
global override Integer size()Returns the number of entries in the map.
Returns Integer — The size of the map.
Example
Integer result = instance.size();values
global List<SObjectField> values()Returns the list of SObjectField values in the map.
Returns SObjectField — A list of SObjectField instances.
Example
UTIL_SObjectDescribe describe = UTIL_SObjectDescribe.getDescribe('Account');
List<SObjectField> fields = describe.getFields().values();
System.debug(fields.size()); // Outputs: Number of fields on Account