Created
September 15, 2019 16:06
-
-
Save DataSolveProblems/4d7c2be86e1bde06baa050b14157fbd7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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