Skip to content

UTIL_SObjectDescribe.GlobalDescribeMap

Class

apex
global inherited sharing class UTIL_SObjectDescribe.GlobalDescribeMap extends UTIL_SObjectDescribe.NamespacedAttributeMap

A subclass of NamespacedAttributeMap for handling global describe data returned by getGlobalDescribe.


Methods

MethodDescription
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 SObjectType get(String name)Retrieves an SObjectType by name with namespace handling enabled by default.
global SObjectType get(String name, Boolean implyNamespace)Retrieves an SObjectType 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<SObjectType> values()Returns the list of SObjectType values in the global describe map.

containsKey

apex
global override Boolean containsKey(String name)

Checks if the map contains a key with namespace handling enabled by default.

Parameters

ParameterTypeDescription
nameStringThe key to check.

Returns Booleantrue if the key exists, false otherwise.

Example

apex
Boolean result = instance.containsKey('myName');
apex
global override Boolean containsKey(String name, Boolean implyNamespace)

Checks if the map contains a key with optional namespace handling.

Parameters

ParameterTypeDescription
nameStringThe key to check.
implyNamespaceBooleanWhether to handle namespace prefixes.

Returns Booleantrue if the key exists, false otherwise.

Example

apex
Boolean result = instance.containsKey('myName', true);

get

apex
global SObjectType get(String name)

Retrieves an SObjectType by name with namespace handling enabled by default.

Parameters

ParameterTypeDescription
nameStringThe API name of the SObject.

Returns SObjectType — The SObjectType, or null if not found.

Example

apex
UTIL_SObjectDescribe.GlobalDescribeMap globalDescribe = UTIL_SObjectDescribe.getGlobalDescribe();
SObjectType objType = globalDescribe.get('Account');
System.debug(objType?.getDescribe().getLabel()); // Outputs: Account
apex
global SObjectType get(String name, Boolean implyNamespace)

Retrieves an SObjectType by name with optional namespace handling.

Parameters

ParameterTypeDescription
nameStringThe API name of the SObject.
implyNamespaceBooleanWhether to handle namespace prefixes.

Returns SObjectType — The SObjectType, or null if not found.

Example

apex
UTIL_SObjectDescribe.GlobalDescribeMap globalDescribe = UTIL_SObjectDescribe.getGlobalDescribe();
SObjectType objType = globalDescribe.get('Account', false);
System.debug(objType?.getDescribe().name); // Outputs: Account

keySet

apex
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

apex
Set<String> result = instance.keySet();
apex
global override Set<String> keySet(Boolean implyNamespace)

Returns the key set of the map with optional namespace handling.

Parameters

ParameterTypeDescription
implyNamespaceBooleanWhether to strip namespace prefixes from keys.

Returns String — A set of keys in the map.

Example

apex
Set<String> result = instance.keySet(true);

size

apex
global override Integer size()

Returns the number of entries in the map.

Returns Integer — The size of the map.

Example

apex
Integer result = instance.size();

values

apex
global List<SObjectType> values()

Returns the list of SObjectType values in the global describe map.

Returns SObjectType — A list of SObjectType instances.

Example

apex
UTIL_SObjectDescribe.GlobalDescribeMap globalDescribe = UTIL_SObjectDescribe.getGlobalDescribe();
List<SObjectType> objTypes = globalDescribe.values();
System.debug(objTypes.size()); // Outputs: Number of SObject types