From f7aa2bbd3975ba10edbce0f809f0b41cac57a67b Mon Sep 17 00:00:00 2001 From: wimvelzeboer Date: Wed, 6 Apr 2022 08:42:45 +0100 Subject: [PATCH] Avoid code duplication Routes other registerNew methods to the bulkified method overload. --- .../main/classes/fflib_SObjectUnitOfWork.cls | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/sfdx-source/apex-common/main/classes/fflib_SObjectUnitOfWork.cls b/sfdx-source/apex-common/main/classes/fflib_SObjectUnitOfWork.cls index 579266d05b6..28feb2d451a 100644 --- a/sfdx-source/apex-common/main/classes/fflib_SObjectUnitOfWork.cls +++ b/sfdx-source/apex-common/main/classes/fflib_SObjectUnitOfWork.cls @@ -252,10 +252,7 @@ public virtual class fflib_SObjectUnitOfWork **/ public void registerNew(List records) { - for (SObject record : records) - { - registerNew(record, null, null); - } + registerNew(records, null, null); } /** @@ -268,16 +265,7 @@ public virtual class fflib_SObjectUnitOfWork **/ public void registerNew(SObject record, Schema.SObjectField relatedToParentField, SObject relatedToParentRecord) { - if (record.Id != null) - throw new UnitOfWorkException('Only new records can be registered as new'); - String sObjectType = record.getSObjectType().getDescribe().getName(); - - assertForNonEventSObjectType(sObjectType); - assertForSupportedSObjectType(m_newListByType, sObjectType); - - m_newListByType.get(sObjectType).add(record); - if (relatedToParentRecord!=null && relatedToParentField!=null) - registerRelationship(record, relatedToParentField, relatedToParentRecord); + registerNew(new List {record}, relatedToParentField, relatedToParentRecord); } /**