Skip to content

Commit 58cb9a3

Browse files
committed
Merge pull request apex-enterprise-patterns#63 from jondavis9898/issue58
Issue apex-enterprise-patterns#58 - add newInstance overload to support performance optimization
2 parents 600ea62 + e73f465 commit 58cb9a3

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

fflib/src/classes/fflib_Application.cls

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,22 @@ public class fflib_Application
6262
return new fflib_SObjectUnitOfWork(m_objectTypes);
6363
}
6464

65+
/**
66+
* Returns a new fflib_SObjectUnitOfWork configured with the
67+
* SObjectType list specified, returns a Mock implementation
68+
* if set via the setMock method
69+
*
70+
* @remark If mock is set, the list of SObjectType in the mock could be different
71+
* then the list of SObjectType specified in this method call
72+
**/
73+
public fflib_ISObjectUnitOfWork newInstance(List<SObjectType> objectTypes)
74+
{
75+
// Mock?
76+
if(m_mockUow!=null)
77+
return m_mockUow;
78+
return new fflib_SObjectUnitOfWork(objectTypes);
79+
}
80+
6581
@TestVisible
6682
private void setMock(fflib_ISObjectUnitOfWork mockUow)
6783
{

0 commit comments

Comments
 (0)