fflib-apex-common icon indicating copy to clipboard operation
fflib-apex-common copied to clipboard

Add domain methods to retrieve maps

Open wimvelzeboer opened this issue 2 years ago • 0 comments

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);
}

This change is Reviewable

wimvelzeboer avatar Apr 06 '22 10:04 wimvelzeboer