Skip to content

Commit 6d8889d

Browse files
committed
add extensions
1 parent 83ac48b commit 6d8889d

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

sfdx-source/apex-common/main/classes/fflib_Application.cls

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ public virtual class fflib_Application
3939
private List<SObjectType> m_objectTypes;
4040
private fflib_ISObjectUnitOfWork m_mockUow;
4141

42+
/**
43+
* Constructs a Unit Of Work factory
44+
**/
45+
public UnitOfWorkFactory() { }
46+
4247
/**
4348
* Constructs a Unit Of Work factory
4449
*
@@ -54,29 +59,27 @@ public virtual class fflib_Application
5459
* SObjectType list provided in the constructor, returns a Mock implementation
5560
* if set via the setMock method
5661
**/
57-
public fflib_ISObjectUnitOfWork newInstance()
62+
public virtual fflib_ISObjectUnitOfWork newInstance()
5863
{
5964
// Mock?
6065
if(m_mockUow!=null)
6166
return m_mockUow;
6267
return new fflib_SObjectUnitOfWork(m_objectTypes);
6368
}
6469

65-
6670
/**
6771
* Returns a new fflib_SObjectUnitOfWork configured with the
6872
* SObjectType list provided in the constructor, returns a Mock implementation
6973
* if set via the setMock method
7074
**/
71-
public fflib_ISObjectUnitOfWork newInstance(fflib_SObjectUnitOfWork.IDML dml)
75+
public virtual fflib_ISObjectUnitOfWork newInstance(fflib_SObjectUnitOfWork.IDML dml)
7276
{
7377
// Mock?
7478
if(m_mockUow!=null)
7579
return m_mockUow;
7680
return new fflib_SObjectUnitOfWork(m_objectTypes, dml);
7781
}
7882

79-
8083
/**
8184
* Returns a new fflib_SObjectUnitOfWork configured with the
8285
* SObjectType list specified, returns a Mock implementation
@@ -85,7 +88,7 @@ public virtual class fflib_Application
8588
* @remark If mock is set, the list of SObjectType in the mock could be different
8689
* then the list of SObjectType specified in this method call
8790
**/
88-
public fflib_ISObjectUnitOfWork newInstance(List<SObjectType> objectTypes)
91+
public virtual fflib_ISObjectUnitOfWork newInstance(List<SObjectType> objectTypes)
8992
{
9093
// Mock?
9194
if(m_mockUow!=null)
@@ -101,17 +104,16 @@ public virtual class fflib_Application
101104
* @remark If mock is set, the list of SObjectType in the mock could be different
102105
* then the list of SObjectType specified in this method call
103106
**/
104-
public fflib_ISObjectUnitOfWork newInstance(List<SObjectType> objectTypes, fflib_SObjectUnitOfWork.IDML dml)
107+
public virtual fflib_ISObjectUnitOfWork newInstance(List<SObjectType> objectTypes, fflib_SObjectUnitOfWork.IDML dml)
105108
{
106109
// Mock?
107110
if(m_mockUow!=null)
108111
return m_mockUow;
109112
return new fflib_SObjectUnitOfWork(objectTypes, dml);
110113
}
111114

112-
113115
@TestVisible
114-
private void setMock(fflib_ISObjectUnitOfWork mockUow)
116+
protected virtual void setMock(fflib_ISObjectUnitOfWork mockUow)
115117
{
116118
m_mockUow = mockUow;
117119
}
@@ -126,6 +128,11 @@ public virtual class fflib_Application
126128

127129
protected Map<Type, Object> m_serviceInterfaceTypeByMockService;
128130

131+
/**
132+
* Constructs a simple Service Factory
133+
**/
134+
public ServiceFactory() { }
135+
129136
/**
130137
* Constructs a simple Service Factory,
131138
* using a Map of Apex Interfaces to Apex Classes implementing the interface
@@ -162,7 +169,7 @@ public virtual class fflib_Application
162169
}
163170

164171
@TestVisible
165-
private virtual void setMock(Type serviceInterfaceType, Object serviceImpl)
172+
protected virtual void setMock(Type serviceInterfaceType, Object serviceImpl)
166173
{
167174
m_serviceInterfaceTypeByMockService.put(serviceInterfaceType, serviceImpl);
168175
}
@@ -176,6 +183,11 @@ public virtual class fflib_Application
176183
protected Map<SObjectType, Type> m_sObjectBySelectorType;
177184
protected Map<SObjectType, fflib_ISObjectSelector> m_sObjectByMockSelector;
178185

186+
/**
187+
* Constructs a simple Selector Factory
188+
**/
189+
public SelectorFactory() { }
190+
179191
/**
180192
* Consturcts a Selector Factory linking SObjectType's with Apex Classes implement the fflib_ISObjectSelector interface
181193
* Note that the factory does not check the given Apex Classes implement the interface
@@ -259,7 +271,7 @@ public virtual class fflib_Application
259271
}
260272

261273
@TestVisible
262-
private virtual void setMock(fflib_ISObjectSelector selectorInstance)
274+
protected virtual void setMock(fflib_ISObjectSelector selectorInstance)
263275
{
264276
m_sObjectByMockSelector.put(selectorInstance.sObjectType(), selectorInstance);
265277
}

0 commit comments

Comments
 (0)