Skip to content

Instantly share code, notes, and snippets.

@DataSolveProblems
Created September 15, 2019 16:06
Show Gist options
  • Save DataSolveProblems/4d7c2be86e1bde06baa050b14157fbd7 to your computer and use it in GitHub Desktop.
Save DataSolveProblems/4d7c2be86e1bde06baa050b14157fbd7 to your computer and use it in GitHub Desktop.
public class Accounts extends fflib_SObjectDomain {
public Accounts(List<Account>sObjectList) {
super(sObjectList);
}
public class Constructor implements fflib_SObjectDomain.IConstructable {
public fflib_SObjectDomain construct(List<SObject>sObjectList) {
return new Accounts(sObjectList);
}
}
public override void onApplyDefaults() {
for (Account acct:(List<Account>)Records) {
acct.Description = 'Domain classes rock!';
}
}
public override void onBeforeUpdate(Map<Id, sObject>existingRecords) {
String rock = 'Domain classes rock!';
List<Account> updatedAccounts = new List<Account>();
for (Account acct:(List<Account>) Records) {
acct.AnnualRevenue = rock.getLevenshteinDistance(acct.Description);
updatedAccounts.add(acct);
}
fflib_SObjectUnitOfWork uow = new fflib_SObjectUnitOfWork(new Schema.SObjectType[] {Account.SObjectType});
uow.registerDirty(updatedAccounts);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment