Collections
An instance of the forvendi.BreezzApi.BreezzCollections class (accessible via forvendi.BreezzApi.COLLECTIONS) provides helper methods for manipulating, extracting, mapping, and grouping Apex collections and SObject records.
extractIdsFromList(List<SObject> records)
Extracts a unique set of record IDs from a list of SObject records.
Signature:
public Set<Id> extractIdsFromList(List<SObject> records)Parameters:
records: List ofSObjectrecords.
Return Value: Set<Id> – Unique set of IDs.
extractIdsFromList(List<SObject> records, SObjectField fieldName)
Extracts a unique set of IDs from a specific lookup or ID field on a list of SObject records.
Signature:
public Set<Id> extractIdsFromList(List<SObject> records, SObjectField fieldName)Parameters:
records: List ofSObjectrecords.fieldName: TheSObjectFieldpointing to the ID/lookup field.
Return Value: Set<Id> – Unique set of IDs.
extractIdsFromList(List<SObject> records, String fieldName)
Extracts a unique set of IDs from a specified field name on a list of SObject records.
Signature:
public Set<Id> extractIdsFromList(List<SObject> records, String fieldName)Parameters:
records: List ofSObjectrecords.fieldName: String API name of the field.
Return Value: Set<Id> – Unique set of IDs.
extractValuesFromList(List<SObject> records, SObjectField fieldName)
Extracts field values from a list of SObject records based on an SObjectField reference.
Signature:
public Set<Object> extractValuesFromList(List<SObject> records, SObjectField fieldName)Parameters:
records: List ofSObjectrecords.fieldName: TheSObjectFieldreference.
Return Value: Set<Object> – Unique set of field values.
extractValuesFromList(List<SObject> records, String fieldName)
Extracts field values from a list of SObject records based on a field API name.
Signature:
public Set<Object> extractValuesFromList(List<SObject> records, String fieldName)Parameters:
records: List ofSObjectrecords.fieldName: String API name of the field.
Return Value: Set<Object> – Unique set of field values.
slice(Object[] arr, Integer first, Integer last)
Slices an array from a start index to an end index.
Signature:
public Object[] slice(Object[] arr, Integer first, Integer last)Parameters:
arr: Target array to slice.first: The starting index.last: The ending index.
Return Value: Object[] – The sliced sub-array.
toIdSet(Set<String> keys)
Converts a Set<String> collection to a Set<Id>.
Signature:
public Set<Id> toIdSet(Set<String> keys)Parameters:
keys: SourceSet<String>.
Return Value: Set<Id> – Converted set of IDs.
toStringSet(Set<Id> keys)
Converts a Set<Id> collection to a Set<String>.
Signature:
public Set<String> toStringSet(Set<Id> keys)Parameters:
keys: SourceSet<Id>.
Return Value: Set<String> – Converted set of Strings.
toIdList(Set<String> keys)
Converts a Set<String> collection to a List<Id>.
Signature:
public List<Id> toIdList(Set<String> keys)Parameters:
keys: SourceSet<String>.
Return Value: List<Id> – Converted list of IDs.
createSObjectList(String objType)
Dynamically creates an empty typed List<SObject> for a specified SObject API name.
Signature:
public List<SObject> createSObjectList(String objType)Parameters:
objType: Salesforce class or SObject API name.
Return Value: List<SObject> – Empty typed list.
createSObjectList(SObjectType objType)
Dynamically creates an empty typed List<SObject> for a specified SObjectType.
Signature:
public List<SObject> createSObjectList(SObjectType objType)Parameters:
objType: SalesforceSObjectTypereference.
Return Value: List<SObject> – Empty typed list.
createSObjectMap(String objType)
Dynamically creates an empty Map<Id, SObject> for a specified SObject API name.
Signature:
public Map<Id, SObject> createSObjectMap(String objType)Parameters:
objType: Salesforce SObject API name.
Return Value: Map<Id, SObject> – Empty typed map.
createSObjectMapGroupByStringValue(String objType)
Dynamically creates an empty Map<String, SObject> for a specified SObject type.
Signature:
public Map<String, SObject> createSObjectMapGroupByStringValue(String objType)Parameters:
objType: Salesforce SObject API name.
Return Value: Map<String, SObject> – Empty map.
createSObjectMapGroupByValue(String objType)
Dynamically creates an empty Map<Object, SObject> for a specified SObject type.
Signature:
public Map<Object, SObject> createSObjectMapGroupByValue(String objType)Parameters:
objType: Salesforce SObject API name.
Return Value: Map<Object, SObject> – Empty map.
createSObjectMapList(String objType)
Dynamically creates an empty Map<Id, List<SObject>> for a specified SObject type.
Signature:
public Map<Id, List<SObject>> createSObjectMapList(String objType)Parameters:
objType: Salesforce SObject API name.
Return Value: Map<Id, List<SObject>> – Empty map of record lists.
createSObjectMapListGroupByStringValue(String objType)
Dynamically creates an empty Map<String, List<SObject>> for a specified SObject type.
Signature:
public Map<String, List<SObject>> createSObjectMapListGroupByStringValue(String objType)Parameters:
objType: Salesforce SObject API name.
Return Value: Map<String, List<SObject>> – Empty map of record lists.
createSObjectMapListGroupByValue(String objType)
Dynamically creates an empty Map<Object, List<SObject>> for a specified SObject type.
Signature:
public Map<Object, List<SObject>> createSObjectMapListGroupByValue(String objType)Parameters:
objType: Salesforce SObject API name.
Return Value: Map<Object, List<SObject>> – Empty map of record lists.
createSObjectMap(SObjectType objType)
Dynamically creates an empty Map<Id, SObject> for a specified SObjectType.
Signature:
public Map<Id, SObject> createSObjectMap(SObjectType objType)Parameters:
objType: SalesforceSObjectTypereference.
Return Value: Map<Id, SObject> – Empty map.
createSObjectMap(SObject[] items)
Populates a Map<Id, SObject> from an array/list of SObject records.
Signature:
public Map<Id, SObject> createSObjectMap(SObject[] items)Parameters:
items: Array or list ofSObjectrecords.
Return Value: Map<Id, SObject> – Populated map keyed by Record ID.
groupUniqueByTextField(SObject[] items, SObjectField fieldName)
Groups records by a unique string value from a specified text field.
Signature:
public Map<String, SObject> groupUniqueByTextField(SObject[] items, SObjectField fieldName)Parameters:
items: Array or list ofSObjectrecords.fieldName: The text field reference used as the map key.
Return Value: Map<String, SObject> – Map keyed by string field values.
groupUniqueByField(SObject[] items, SObjectField fieldName)
Groups records by a unique value from any specified field.
Signature:
public Map<Object, SObject> groupUniqueByField(SObject[] items, SObjectField fieldName)Parameters:
items: Array or list ofSObjectrecords.fieldName: The field reference used as the map key.
Return Value: Map<Object, SObject> – Map keyed by field values.
groupByTextField(SObject[] items, SObjectField fieldName)
Groups multiple records into lists, keyed by a specified text field.
Signature:
public Map<String, List<SObject>> groupByTextField(SObject[] items, SObjectField fieldName)Parameters:
items: Array or list ofSObjectrecords.fieldName: The text field reference used as the group key.
Return Value: Map<String, List<SObject>> – Map of record lists keyed by string values.
groupByField(SObject[] items, SObjectField fieldName)
Groups multiple records into lists, keyed by any specified field.
Signature:
public Map<Object, List<SObject>> groupByField(SObject[] items, SObjectField fieldName)Parameters:
items: Array or list ofSObjectrecords.fieldName: The field reference used as the group key.
Return Value: Map<Object, List<SObject>> – Map of record lists keyed by field values.