fflib-apex-common
fflib-apex-common copied to clipboard
Add domain methods to retrieve maps
Often we retrieve data from records in maps, these domain methods will help with avoiding iterations.
Account accounts = Accounts.newInstance(records);
Map<Id, String> accountNameById = accounts.getStringFieldByIdField(Account.AccountName, Account.Id);
instead of:
Account accounts = Accounts.newInstance(records);
Map<Id, String> accountNameById = new Map<Id, String>();
for (Account record : (List<Account) accounts.getRecords())
{
accountNameById.put(record.Id, record.Name);
}