-
Notifications
You must be signed in to change notification settings - Fork 460
IterationRecipes
pozil edited this page Nov 14, 2024
·
12 revisions
Demonstrates how to iterate on lists and sets
Group Collection Recipes
Demonstrates how to iterate on a list of SObject thanks to the Iterable and Iterator interfaces.
This example iterates on Accounts to sum the 'number of employees' field values
(use the SUM
SOQL function for a real-life application).
public static Integer iterateOnAccountList(List<Account> accounts)
Name | Type | Description |
---|---|---|
accounts | List<Account> | a list of accounts that will be iterated on |
Integer
Total number of employees for the accounts
Demonstrates how to use a REST API client that leverages the Iterator
interface.
This example iterates on a paginated record list. Records are represented as strings for simplicity.
Remote records are retrieved on the fly by IterableApiClient when the Iterator is accessed.
public static List<String> iterableApiClientRecipe()
List<String>
List of "records" retrieved