Add "fflib_" prefix to primitive domain classes

This commit is contained in:
wim
2021-10-05 10:22:23 +01:00
parent f3ee423925
commit a358fef3c9
29 changed files with 172 additions and 171 deletions
@@ -1,5 +1,5 @@
public inherited sharing class ${NAME} public inherited sharing class ${NAME}
extends SObjects extends fflib_SObjects2
implements I${NAME} implements I${NAME}
{ {
public static I${NAME} newInstance(List<${SObject_API_Name}> records) public static I${NAME} newInstance(List<${SObject_API_Name}> records)
+1 -1
View File
@@ -41,7 +41,7 @@ How it can be applied in a Domain class:
```apex ```apex
public with sharing class Accounts public with sharing class Accounts
extends SObjects extends fflib_SObjects2
implements IAccounts implements IAccounts
{ {
private static final Integer LARGE_ACCOUNT_EMPLOYEE_NUMBERS = 500; private static final Integer LARGE_ACCOUNT_EMPLOYEE_NUMBERS = 500;
+1 -1
View File
@@ -6,7 +6,7 @@ The primitive domain SObject adds a lot of additional getter methods to the doma
This class should be used to extend Domain classes. This class should be used to extend Domain classes.
```apex ```apex
public class Accounts extends SObjects implements IAccounts public class Accounts extends fflib_SObjects2 implements IAccounts
{ {
... ...
} }
+2 -1
View File
@@ -8,8 +8,9 @@ Instead of:
List<String> myStrings = getSomeStrings(); List<String> myStrings = getSomeStrings();
``` ```
You can write: You can write:
```apex ```apex
Strings myStrings = getSomeString(); fflib_Strings myStrings = getSomeString();
``` ```
It is a small thing, but it makes things looks much nicer. It is a small thing, but it makes things looks much nicer.
@@ -120,7 +120,7 @@ public virtual class fflib_DynamicSelectorFactory
return this; return this;
} }
private class RelatedRecordsDomain extends SObjects private class RelatedRecordsDomain extends fflib_SObjects2
{ {
public RelatedRecordsDomain(List<SObject> records) public RelatedRecordsDomain(List<SObject> records)
{ {
@@ -536,35 +536,35 @@ public virtual with sharing class fflib_Criteria
// Method overrides // Method overrides
public fflib_Criteria inSet(Schema.SObjectField field, Set<Date> values) public fflib_Criteria inSet(Schema.SObjectField field, Set<Date> values)
{ {
return inSet(field, new Dates(values)); return inSet(field, new fflib_Dates(values));
} }
public fflib_Criteria inSet(Schema.SObjectField field, Set<Datetime> values) public fflib_Criteria inSet(Schema.SObjectField field, Set<Datetime> values)
{ {
return inSet(field, new DateTimes(values)); return inSet(field, new fflib_DateTimes(values));
} }
public fflib_Criteria inSet(Schema.SObjectField field, Set<Decimal> values) public fflib_Criteria inSet(Schema.SObjectField field, Set<Decimal> values)
{ {
return inSet(field, new Decimals(values)); return inSet(field, new fflib_Decimals(values));
} }
public fflib_Criteria inSet(Schema.SObjectField field, Set<Double> values) public fflib_Criteria inSet(Schema.SObjectField field, Set<Double> values)
{ {
return inSet(field, new Doubles(values)); return inSet(field, new fflib_Doubles(values));
} }
public fflib_Criteria inSet(Schema.SObjectField field, Set<Id> values) public fflib_Criteria inSet(Schema.SObjectField field, Set<Id> values)
{ {
return inSet(field, new Ids(values)); return inSet(field, new fflib_Ids(values));
} }
public fflib_Criteria inSet(Schema.SObjectField field, Set<Integer> values) public fflib_Criteria inSet(Schema.SObjectField field, Set<Integer> values)
{ {
return inSet(field, new Integers(values)); return inSet(field, new fflib_Integers(values));
} }
public fflib_Criteria inSet(Schema.SObjectField field, Set<Long> values) public fflib_Criteria inSet(Schema.SObjectField field, Set<Long> values)
{ {
return inSet(field, new Longs(values)); return inSet(field, new fflib_Longs(values));
} }
public fflib_Criteria inSet(Schema.SObjectField field, Set<String> values) public fflib_Criteria inSet(Schema.SObjectField field, Set<String> values)
{ {
return inSet(field, new Strings(values)); return inSet(field, new fflib_Strings(values));
} }
/** /**
* checks if the given sets contains the fields values * checks if the given sets contains the fields values
@@ -604,35 +604,35 @@ public virtual with sharing class fflib_Criteria
*/ */
public fflib_Criteria notInSet(Schema.SObjectField field, Set<Date> values) public fflib_Criteria notInSet(Schema.SObjectField field, Set<Date> values)
{ {
return notInSet(field, new Dates(values)); return notInSet(field, new fflib_Dates(values));
} }
public fflib_Criteria notInSet(Schema.SObjectField field, Set<Datetime> values) public fflib_Criteria notInSet(Schema.SObjectField field, Set<Datetime> values)
{ {
return notInSet(field, new DateTimes(values)); return notInSet(field, new fflib_DateTimes(values));
} }
public fflib_Criteria notInSet(Schema.SObjectField field, Set<Decimal> values) public fflib_Criteria notInSet(Schema.SObjectField field, Set<Decimal> values)
{ {
return notInSet(field, new Decimals(values)); return notInSet(field, new fflib_Decimals(values));
} }
public fflib_Criteria notInSet(Schema.SObjectField field, Set<Double> values) public fflib_Criteria notInSet(Schema.SObjectField field, Set<Double> values)
{ {
return notInSet(field, new Doubles(values)); return notInSet(field, new fflib_Doubles(values));
} }
public fflib_Criteria notInSet(Schema.SObjectField field, Set<Id> values) public fflib_Criteria notInSet(Schema.SObjectField field, Set<Id> values)
{ {
return notInSet(field, new Ids(values)); return notInSet(field, new fflib_Ids(values));
} }
public fflib_Criteria notInSet(Schema.SObjectField field, Set<Integer> values) public fflib_Criteria notInSet(Schema.SObjectField field, Set<Integer> values)
{ {
return notInSet(field, new Integers(values)); return notInSet(field, new fflib_Integers(values));
} }
public fflib_Criteria notInSet(Schema.SObjectField field, Set<Long> values) public fflib_Criteria notInSet(Schema.SObjectField field, Set<Long> values)
{ {
return notInSet(field, new Longs(values)); return notInSet(field, new fflib_Longs(values));
} }
public fflib_Criteria notInSet(Schema.SObjectField field, Set<String> values) public fflib_Criteria notInSet(Schema.SObjectField field, Set<String> values)
{ {
return notInSet(field, new Strings(values)); return notInSet(field, new fflib_Strings(values));
} }
public fflib_Criteria notInSet(Schema.SObjectField field, Set<Object> values) public fflib_Criteria notInSet(Schema.SObjectField field, Set<Object> values)
{ {
@@ -1,5 +1,5 @@
/** /**
* File Name: DateTimes * File Name: fflib_DateTimes
* @description Primitive domain for the object type DateTime * @description Primitive domain for the object type DateTime
* *
* @author architect ir. Wilhelmus G.J. Velzeboer * @author architect ir. Wilhelmus G.J. Velzeboer
@@ -28,20 +28,20 @@
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
public virtual with sharing class DateTimes public virtual with sharing class fflib_DateTimes
extends Objects extends fflib_Objects2
{ {
public DateTimes(Set<Datetime> dateTimes) public fflib_DateTimes(Set<Datetime> dateTimes)
{ {
super(new List<Datetime>(dateTimes)); super(new List<Datetime>(dateTimes));
} }
public DateTimes(List<Datetime> dateTimes) public fflib_DateTimes(List<Datetime> dateTimes)
{ {
super((List<Object>) dateTimes); super((List<Object>) dateTimes);
} }
public DateTimes(List<Object> elements) public fflib_DateTimes(List<Object> elements)
{ {
super(elements); super(elements);
} }
@@ -1,5 +1,5 @@
/** /**
* File Name: Dates * File Name: fflib_Dates
* @description Primitive domain for the object type Date * @description Primitive domain for the object type Date
* *
* @author architect ir. Wilhelmus G.J. Velzeboer * @author architect ir. Wilhelmus G.J. Velzeboer
@@ -28,20 +28,20 @@
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
public virtual class Dates public virtual class fflib_Dates
extends Objects extends fflib_Objects2
{ {
public Dates(Set<Date> dates) public fflib_Dates(Set<Date> dates)
{ {
super(new List<Date>(dates)); super(new List<Date>(dates));
} }
public Dates(List<Date> dates) public fflib_Dates(List<Date> dates)
{ {
super((List<Object>) dates); super((List<Object>) dates);
} }
public Dates(List<Object> elements) public fflib_Dates(List<Object> elements)
{ {
super(elements); super(elements);
} }
@@ -1,5 +1,5 @@
/** /**
* File Name: Decimals * File Name: fflib_Decimals
* @description Primitive domain for the object type Decimal * @description Primitive domain for the object type Decimal
* *
* @author architect ir. Wilhelmus G.J. Velzeboer * @author architect ir. Wilhelmus G.J. Velzeboer
@@ -28,20 +28,20 @@
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
public virtual with sharing class Decimals public virtual with sharing class fflib_Decimals
extends Objects extends fflib_Objects2
{ {
public Decimals(Set<Decimal> decimals) public fflib_Decimals(Set<Decimal> decimals)
{ {
super(new List<Decimal>(decimals)); super(new List<Decimal>(decimals));
} }
public Decimals(List<Decimal> decimals) public fflib_Decimals(List<Decimal> decimals)
{ {
super((List<Object>) decimals); super((List<Object>) decimals);
} }
public Decimals(List<Object> elements) public fflib_Decimals(List<Object> elements)
{ {
super(elements); super(elements);
} }
@@ -1,5 +1,5 @@
/** /**
* File Name: Doubles * File Name: fflib_Doubles
* @description Primitive domain for the object type Double * @description Primitive domain for the object type Double
* *
* @author architect ir. Wilhelmus G.J. Velzeboer * @author architect ir. Wilhelmus G.J. Velzeboer
@@ -28,20 +28,20 @@
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
public virtual with sharing class Doubles public virtual with sharing class fflib_Doubles
extends Objects extends fflib_Objects2
{ {
public Doubles(Set<Double> doubles) public fflib_Doubles(Set<Double> doubles)
{ {
super(new List<Double>(doubles)); super(new List<Double>(doubles));
} }
public Doubles(List<Double> doubles) public fflib_Doubles(List<Double> doubles)
{ {
super((List<Object>) doubles); super((List<Object>) doubles);
} }
public Doubles(List<Object> elements) public fflib_Doubles(List<Object> elements)
{ {
super(elements); super(elements);
} }
@@ -1,5 +1,5 @@
/** /**
* File Name: Ids * File Name: fflib_Ids
* @description Primitive domain for the object type Id * @description Primitive domain for the object type Id
* *
* @author architect ir. Wilhelmus G.J. Velzeboer * @author architect ir. Wilhelmus G.J. Velzeboer
@@ -28,25 +28,25 @@
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
public virtual with sharing class Ids public virtual with sharing class fflib_Ids
extends Objects extends fflib_Objects2
{ {
public Ids(Set<Id> idSet) public fflib_Ids(Set<Id> idSet)
{ {
super(new List<Id>(idSet)); super(new List<Id>(idSet));
} }
public Ids(List<Id> ids) public fflib_Ids(List<Id> ids)
{ {
super((List<Object>) ids); super((List<Object>) ids);
} }
public Ids(List<Object> elements) public fflib_Ids(List<Object> elements)
{ {
super(elements); super(elements);
} }
public Ids(fflib_Objects objects) public fflib_Ids(fflib_Objects objects)
{ {
super(getIdList(objects)); super(getIdList(objects));
} }
@@ -1,5 +1,5 @@
/** /**
* File Name: Integers * File Name: fflib_Integers
* @description Primitive domain for the object type Integer * @description Primitive domain for the object type Integer
* *
* @author architect ir. Wilhelmus G.J. Velzeboer * @author architect ir. Wilhelmus G.J. Velzeboer
@@ -28,20 +28,20 @@
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
public virtual with sharing class Integers public virtual with sharing class fflib_Integers
extends Objects extends fflib_Objects2
{ {
public Integers(Set<Integer> integerSet) public fflib_Integers(Set<Integer> integerSet)
{ {
super(new List<Integer>(integerSet)); super(new List<Integer>(integerSet));
} }
public Integers(List<Integer> integerList) public fflib_Integers(List<Integer> integerList)
{ {
super((List<Integer>) integerList); super((List<Integer>) integerList);
} }
public Integers(List<Object> elements) public fflib_Integers(List<Object> elements)
{ {
super(elements); super(elements);
} }
@@ -1,5 +1,5 @@
/** /**
* File Name: Longs * File Name: fflib_Longs
* @description Primitive domain for the object type Long * @description Primitive domain for the object type Long
* *
* @author architect ir. Wilhelmus G.J. Velzeboer * @author architect ir. Wilhelmus G.J. Velzeboer
@@ -28,20 +28,20 @@
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
public virtual with sharing class Longs public virtual with sharing class fflib_Longs
extends Objects extends fflib_Objects2
{ {
public Longs(Set<Long> longs) public fflib_Longs(Set<Long> longs)
{ {
super(new List<Long>(longs)); super(new List<Long>(longs));
} }
public Longs(List<Long> longs) public fflib_Longs(List<Long> longs)
{ {
super((List<Object>) longs); super((List<Object>) longs);
} }
public Longs(List<Object> elements) public fflib_Longs(List<Object> elements)
{ {
super(elements); super(elements);
} }
@@ -1,5 +1,5 @@
/** /**
* File Name: Objects * File Name: fflib_Objects2
* @description Primitive domain for the type object * @description Primitive domain for the type object
* *
* @author architect ir. Wilhelmus G.J. Velzeboer * @author architect ir. Wilhelmus G.J. Velzeboer
@@ -28,10 +28,10 @@
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
public virtual with sharing class Objects public virtual with sharing class fflib_Objects2
extends fflib_Objects extends fflib_Objects
{ {
public Objects(List<Object> elements) public fflib_Objects2(List<Object> elements)
{ {
super(elements); super(elements);
} }
@@ -1,5 +1,5 @@
/** /**
* File Name: SObjects * File Name: fflib_SObjects2
* @description Primitive domain for the object type SObject * @description Primitive domain for the object type SObject
* *
* @author architect ir. Wilhelmus G.J. Velzeboer * @author architect ir. Wilhelmus G.J. Velzeboer
@@ -28,7 +28,7 @@
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
public virtual class SObjects public virtual class fflib_SObjects2
extends fflib_SObjects extends fflib_SObjects
implements fflib_ISObjects implements fflib_ISObjects
{ {
@@ -39,7 +39,7 @@ public virtual class SObjects
* *
* @param objects The Objects of type SObjectType, to contain inside the domain * @param objects The Objects of type SObjectType, to contain inside the domain
*/ */
public SObjects(List<Object> objects) public fflib_SObjects2(List<Object> objects)
{ {
// todo - assert of objects of type SObject // todo - assert of objects of type SObject
this((List<SObject>) objects); this((List<SObject>) objects);
@@ -50,7 +50,7 @@ public virtual class SObjects
* *
* @param records The records to contain inside the domain * @param records The records to contain inside the domain
*/ */
public SObjects(List<SObject> records) public fflib_SObjects2(List<SObject> records)
{ {
this(records, records.getSObjectType()); this(records, records.getSObjectType());
} }
@@ -61,7 +61,7 @@ public virtual class SObjects
* @param records The records to contain inside the domain * @param records The records to contain inside the domain
* @param sObjectType The SObjectType of the records * @param sObjectType The SObjectType of the records
*/ */
public SObjects(List<SObject> records, Schema.SObjectType sObjectType) public fflib_SObjects2(List<SObject> records, Schema.SObjectType sObjectType)
{ {
super(records, sObjectType); super(records, sObjectType);
SObjectDescribe = sObjectType.getDescribe(); SObjectDescribe = sObjectType.getDescribe();
@@ -92,7 +92,7 @@ public virtual class SObjects
* *
* @return Returns only the SObjects from the domain matching the given Ids. * @return Returns only the SObjects from the domain matching the given Ids.
*/ */
public virtual List<SObject> getRecords(Ids ids) public virtual List<SObject> getRecords(fflib_Ids ids)
{ {
return getRecords(ids.getIds()); return getRecords(ids.getIds());
} }
@@ -193,7 +193,7 @@ public virtual class SObjects
* @return The Date values of the given sObjectField, null values are omitted * @return The Date values of the given sObjectField, null values are omitted
*/ */
@TestVisible @TestVisible
protected virtual Dates getDateFieldValues(Schema.SObjectField sObjectField) protected virtual fflib_Dates getDateFieldValues(Schema.SObjectField sObjectField)
{ {
Set<Date> result = new Set<Date>(); Set<Date> result = new Set<Date>();
for (SObject record : getRecords()) for (SObject record : getRecords())
@@ -202,7 +202,7 @@ public virtual class SObjects
if (fieldValue == null) continue; if (fieldValue == null) continue;
result.add((Date) fieldValue); result.add((Date) fieldValue);
} }
return new Dates(result); return new fflib_Dates(result);
} }
/** /**
@@ -212,9 +212,9 @@ public virtual class SObjects
* @return The Date values of the given sObjectField, null values are omitted * @return The Date values of the given sObjectField, null values are omitted
*/ */
@TestVisible @TestVisible
protected virtual Dates getDateFieldValues(Schema.SObjectField sObjectField, fflib_Criteria criteria) protected virtual fflib_Dates getDateFieldValues(Schema.SObjectField sObjectField, fflib_Criteria criteria)
{ {
return new SObjects(getRecords(criteria), getSObjectType()) return new fflib_SObjects2(getRecords(criteria), getSObjectType())
.getDateFieldValues(sObjectField); .getDateFieldValues(sObjectField);
} }
@@ -224,7 +224,7 @@ public virtual class SObjects
* @return The DateTime values of the given sObjectField, null values are omitted * @return The DateTime values of the given sObjectField, null values are omitted
*/ */
@TestVisible @TestVisible
protected virtual DateTimes getDateTimeFieldValues(Schema.SObjectField sObjectField) protected virtual fflib_DateTimes getDateTimeFieldValues(Schema.SObjectField sObjectField)
{ {
Set<Datetime> result = new Set<Datetime>(); Set<Datetime> result = new Set<Datetime>();
for (SObject record : getRecords()) for (SObject record : getRecords())
@@ -233,7 +233,7 @@ public virtual class SObjects
if (fieldValue == null) continue; if (fieldValue == null) continue;
result.add((Datetime) fieldValue); result.add((Datetime) fieldValue);
} }
return new DateTimes(result); return new fflib_DateTimes(result);
} }
/** /**
@@ -243,9 +243,9 @@ public virtual class SObjects
* @return The DateTime values of the given sObjectField, null values are omitted * @return The DateTime values of the given sObjectField, null values are omitted
*/ */
@TestVisible @TestVisible
protected virtual DateTimes getDateTimeFieldValues(Schema.SObjectField sObjectField, fflib_Criteria criteria) protected virtual fflib_DateTimes getDateTimeFieldValues(Schema.SObjectField sObjectField, fflib_Criteria criteria)
{ {
return new SObjects(getRecords(criteria), getSObjectType()) return new fflib_SObjects2(getRecords(criteria), getSObjectType())
.getDateTimeFieldValues(sObjectField); .getDateTimeFieldValues(sObjectField);
} }
@@ -255,7 +255,7 @@ public virtual class SObjects
* @return The Decimal values of the given sObjectField, null values are omitted * @return The Decimal values of the given sObjectField, null values are omitted
*/ */
@TestVisible @TestVisible
protected virtual Decimals getDecimalFieldValues(Schema.SObjectField sObjectField) protected virtual fflib_Decimals getDecimalFieldValues(Schema.SObjectField sObjectField)
{ {
Set<Decimal> result = new Set<Decimal>(); Set<Decimal> result = new Set<Decimal>();
for (SObject record : getRecords()) for (SObject record : getRecords())
@@ -264,7 +264,7 @@ public virtual class SObjects
if (fieldValue == null) continue; if (fieldValue == null) continue;
result.add((Decimal) fieldValue); result.add((Decimal) fieldValue);
} }
return new Decimals(result); return new fflib_Decimals(result);
} }
/** /**
@@ -274,9 +274,9 @@ public virtual class SObjects
* @return The Decimal values of the given sObjectField, null values are omitted * @return The Decimal values of the given sObjectField, null values are omitted
*/ */
@TestVisible @TestVisible
protected virtual Decimals getDecimalFieldValues(Schema.SObjectField sObjectField, fflib_Criteria criteria) protected virtual fflib_Decimals getDecimalFieldValues(Schema.SObjectField sObjectField, fflib_Criteria criteria)
{ {
return new SObjects(getRecords(criteria), getSObjectType()) return new fflib_SObjects2(getRecords(criteria), getSObjectType())
.getDecimalFieldValues(sObjectField); .getDecimalFieldValues(sObjectField);
} }
@@ -286,7 +286,7 @@ public virtual class SObjects
* @return The Double values of the given sObjectField, null values are omitted * @return The Double values of the given sObjectField, null values are omitted
*/ */
@TestVisible @TestVisible
protected virtual Doubles getDoubleFieldValues(Schema.SObjectField sObjectField) protected virtual fflib_Doubles getDoubleFieldValues(Schema.SObjectField sObjectField)
{ {
Set<Double> result = new Set<Double>(); Set<Double> result = new Set<Double>();
for (SObject record : getRecords()) for (SObject record : getRecords())
@@ -295,7 +295,7 @@ public virtual class SObjects
if (fieldValue == null) continue; if (fieldValue == null) continue;
result.add((Double) fieldValue); result.add((Double) fieldValue);
} }
return new Doubles(result); return new fflib_Doubles(result);
} }
/** /**
@@ -305,9 +305,9 @@ public virtual class SObjects
* @return The Double values of the given sObjectField, null values are omitted * @return The Double values of the given sObjectField, null values are omitted
*/ */
@TestVisible @TestVisible
protected virtual Doubles getDoubleFieldValues(Schema.SObjectField sObjectField, fflib_Criteria criteria) protected virtual fflib_Doubles getDoubleFieldValues(Schema.SObjectField sObjectField, fflib_Criteria criteria)
{ {
return new SObjects(getRecords(criteria), getSObjectType()) return new fflib_SObjects2(getRecords(criteria), getSObjectType())
.getDoubleFieldValues(sObjectField); .getDoubleFieldValues(sObjectField);
} }
@@ -440,7 +440,7 @@ public virtual class SObjects
* @return The Id values of the given sObjectField, null values are omitted * @return The Id values of the given sObjectField, null values are omitted
*/ */
@TestVisible @TestVisible
protected virtual Ids getIdFieldValues(Schema.SObjectField sObjectField) protected virtual fflib_Ids getIdFieldValues(Schema.SObjectField sObjectField)
{ {
Set<Id> result = new Set<Id>(); Set<Id> result = new Set<Id>();
for (SObject record : getRecords()) for (SObject record : getRecords())
@@ -450,7 +450,7 @@ public virtual class SObjects
result.add(Id.valueOf(String.valueOf(fieldValue))); result.add(Id.valueOf(String.valueOf(fieldValue)));
} }
return new Ids(result); return new fflib_Ids(result);
// todo - alternative return to avoid code duplications: return new Ids(getFieldValues(sObjectField)); // todo - alternative return to avoid code duplications: return new Ids(getFieldValues(sObjectField));
} }
@@ -461,9 +461,9 @@ public virtual class SObjects
* @return The Id values of the given sObjectField, null values are omitted * @return The Id values of the given sObjectField, null values are omitted
*/ */
@TestVisible @TestVisible
protected virtual Ids getIdFieldValues(Schema.SObjectField sObjectField, fflib_Criteria criteria) protected virtual fflib_Ids getIdFieldValues(Schema.SObjectField sObjectField, fflib_Criteria criteria)
{ {
return new SObjects(getRecords(criteria), getSObjectType()) return new fflib_SObjects2(getRecords(criteria), getSObjectType())
.getIdFieldValues(sObjectField); .getIdFieldValues(sObjectField);
} }
@@ -473,7 +473,7 @@ public virtual class SObjects
* @return The Integer values of the given sObjectField, null values are omitted * @return The Integer values of the given sObjectField, null values are omitted
*/ */
@TestVisible @TestVisible
protected virtual Integers getIntegerFieldValues(Schema.SObjectField sObjectField) protected virtual fflib_Integers getIntegerFieldValues(Schema.SObjectField sObjectField)
{ {
Set<Integer> result = new Set<Integer>(); Set<Integer> result = new Set<Integer>();
for (SObject record : getRecords()) for (SObject record : getRecords())
@@ -483,7 +483,7 @@ public virtual class SObjects
result.add(Integer.valueOf(fieldValue)); result.add(Integer.valueOf(fieldValue));
} }
return new Integers(result); return new fflib_Integers(result);
} }
/** /**
@@ -493,9 +493,9 @@ public virtual class SObjects
* @return The Integer values of the given sObjectField, null values are omitted * @return The Integer values of the given sObjectField, null values are omitted
*/ */
@TestVisible @TestVisible
protected virtual Integers getIntegerFieldValues(Schema.SObjectField sObjectField, fflib_Criteria criteria) protected virtual fflib_Integers getIntegerFieldValues(Schema.SObjectField sObjectField, fflib_Criteria criteria)
{ {
return new SObjects(getRecords(criteria), getSObjectType()) return new fflib_SObjects2(getRecords(criteria), getSObjectType())
.getIntegerFieldValues(sObjectField); .getIntegerFieldValues(sObjectField);
} }
@@ -505,7 +505,7 @@ public virtual class SObjects
* @return The Long values of the given sObjectField, null values are omitted * @return The Long values of the given sObjectField, null values are omitted
*/ */
@TestVisible @TestVisible
protected virtual Longs getLongFieldValues(Schema.SObjectField sObjectField) protected virtual fflib_Longs getLongFieldValues(Schema.SObjectField sObjectField)
{ {
Set<Long> result = new Set<Long>(); Set<Long> result = new Set<Long>();
for (SObject record : getRecords()) for (SObject record : getRecords())
@@ -514,7 +514,7 @@ public virtual class SObjects
if (fieldValue == null) continue; if (fieldValue == null) continue;
result.add((Long) fieldValue); result.add((Long) fieldValue);
} }
return new Longs(result); return new fflib_Longs(result);
} }
/** /**
@@ -524,9 +524,9 @@ public virtual class SObjects
* @return The Long values of the given sObjectField, null values are omitted * @return The Long values of the given sObjectField, null values are omitted
*/ */
@TestVisible @TestVisible
protected virtual Longs getLongFieldValues(Schema.SObjectField sObjectField, fflib_Criteria criteria) protected virtual fflib_Longs getLongFieldValues(Schema.SObjectField sObjectField, fflib_Criteria criteria)
{ {
return new SObjects(getRecords(criteria), getSObjectType()) return new fflib_SObjects2(getRecords(criteria), getSObjectType())
.getLongFieldValues(sObjectField); .getLongFieldValues(sObjectField);
} }
@@ -699,14 +699,14 @@ public virtual class SObjects
* @return The String values of the given sObjectField * @return The String values of the given sObjectField
*/ */
@TestVisible @TestVisible
protected virtual Strings getStringFieldValues(Schema.SObjectField sObjectField) protected virtual fflib_Strings getStringFieldValues(Schema.SObjectField sObjectField)
{ {
Set<String> result = new Set<String>(); Set<String> result = new Set<String>();
for (SObject record : getRecords()) for (SObject record : getRecords())
{ {
result.add(String.valueOf(record.get(sObjectField))); result.add(String.valueOf(record.get(sObjectField)));
} }
return new Strings(result); return new fflib_Strings(result);
} }
/** /**
@@ -716,9 +716,9 @@ public virtual class SObjects
* @return The String values of the given sObjectField * @return The String values of the given sObjectField
*/ */
@TestVisible @TestVisible
protected virtual Strings getStringFieldValues(Schema.SObjectField sObjectField, fflib_Criteria criteria) protected virtual fflib_Strings getStringFieldValues(Schema.SObjectField sObjectField, fflib_Criteria criteria)
{ {
return new SObjects(getRecords(criteria), getSObjectType()) return new fflib_SObjects2(getRecords(criteria), getSObjectType())
.getStringFieldValues(sObjectField); .getStringFieldValues(sObjectField);
} }
@@ -732,7 +732,7 @@ public virtual class SObjects
@TestVisible @TestVisible
protected virtual void setFieldValue(Schema.SObjectField sObjectField, Object value, fflib_Criteria criteria) protected virtual void setFieldValue(Schema.SObjectField sObjectField, Object value, fflib_Criteria criteria)
{ {
new SObjects(getRecords(criteria), getSObjectType()) new fflib_SObjects2(getRecords(criteria), getSObjectType())
.setFieldValue(sObjectField, value); .setFieldValue(sObjectField, value);
} }
} }
@@ -1,5 +1,5 @@
/** /**
* File Name: Strings * File Name: fflib_Strings
* @description Primitive domain for the object type String * @description Primitive domain for the object type String
* *
* @author architect ir. Wilhelmus G.J. Velzeboer * @author architect ir. Wilhelmus G.J. Velzeboer
@@ -28,20 +28,20 @@
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
public virtual with sharing class Strings public virtual with sharing class fflib_Strings
extends Objects extends fflib_Objects2
{ {
public Strings(Set<String> stringSet) public fflib_Strings(Set<String> stringSet)
{ {
super(new List<String>(stringSet)); super(new List<String>(stringSet));
} }
public Strings(List<String> stringList) public fflib_Strings(List<String> stringList)
{ {
super(stringList); super(stringList);
} }
public Strings(List<Object> elements) public fflib_Strings(List<Object> elements)
{ {
super(elements); super(elements);
@@ -80,7 +80,7 @@ private class fflib_ClassicDomainFactoryTest
} }
} }
public class MyDomain extends SObjects public class MyDomain extends fflib_SObjects2
{ {
public MyDomain(List<Account> records) public MyDomain(List<Account> records)
{ {
@@ -48,9 +48,9 @@ private class PrimitiveDomainsTest
Date.newInstance(2022, 02, 02) Date.newInstance(2022, 02, 02)
}; };
Dates datesA = new Dates(dateSet); fflib_Dates datesA = new fflib_Dates(dateSet);
Dates DatesB = new Dates(dateList); fflib_Dates DatesB = new fflib_Dates(dateList);
Dates DatesC = new Dates((List<Object>) dateList); fflib_Dates DatesC = new fflib_Dates((List<Object>) dateList);
System.assert(datesA.getDateSet().containsAll(DatesB.getDates())); System.assert(datesA.getDateSet().containsAll(DatesB.getDates()));
System.assert(datesA.getDateSet().containsAll(DatesC.getDates())); System.assert(datesA.getDateSet().containsAll(DatesC.getDates()));
@@ -73,9 +73,9 @@ private class PrimitiveDomainsTest
Datetime.newInstance(2022, 02, 02, 01, 00, 00) Datetime.newInstance(2022, 02, 02, 01, 00, 00)
}; };
DateTimes datetimeA = new DateTimes(dateSet); fflib_DateTimes datetimeA = new fflib_DateTimes(dateSet);
DateTimes datetimeB = new DateTimes(dateList); fflib_DateTimes datetimeB = new fflib_DateTimes(dateList);
DateTimes datetimeC = new DateTimes((List<Object>) dateList); fflib_DateTimes datetimeC = new fflib_DateTimes((List<Object>) dateList);
System.assert(datetimeA.getDateTimeSet().containsAll(datetimeB.getDateTimes())); System.assert(datetimeA.getDateTimeSet().containsAll(datetimeB.getDateTimes()));
System.assert(datetimeA.getDateTimeSet().containsAll(datetimeC.getDateTimes())); System.assert(datetimeA.getDateTimeSet().containsAll(datetimeC.getDateTimes()));
@@ -87,9 +87,9 @@ private class PrimitiveDomainsTest
final Set<Decimal> dataSet = new Set<Decimal> {5.5, 1.1, -1.1, -2.7}; final Set<Decimal> dataSet = new Set<Decimal> {5.5, 1.1, -1.1, -2.7};
final List<Decimal> dataList = new List<Decimal> {5.5, 1.1, -1.1, -2.7}; final List<Decimal> dataList = new List<Decimal> {5.5, 1.1, -1.1, -2.7};
Decimals domainA = new Decimals(dataSet); fflib_Decimals domainA = new fflib_Decimals(dataSet);
Decimals domainB = new Decimals(dataList); fflib_Decimals domainB = new fflib_Decimals(dataList);
Decimals domainC = new Decimals((List<Object>) dataList); fflib_Decimals domainC = new fflib_Decimals((List<Object>) dataList);
System.assert(domainA.getDecimalSet().containsAll(domainB.getDecimals())); System.assert(domainA.getDecimalSet().containsAll(domainB.getDecimals()));
System.assert(domainA.getDecimalSet().containsAll(domainC.getDecimals())); System.assert(domainA.getDecimalSet().containsAll(domainC.getDecimals()));
@@ -101,9 +101,9 @@ private class PrimitiveDomainsTest
final Set<Double> dataSet = new Set<Double> {1261992, 3.14159265}; final Set<Double> dataSet = new Set<Double> {1261992, 3.14159265};
final List<Double> dataList = new List<Double> {1261992, 3.14159265}; final List<Double> dataList = new List<Double> {1261992, 3.14159265};
Doubles domainA = new Doubles(dataSet); fflib_Doubles domainA = new fflib_Doubles(dataSet);
Doubles domainB = new Doubles(dataList); fflib_Doubles domainB = new fflib_Doubles(dataList);
Doubles domainC = new Doubles((List<Object>) dataList); fflib_Doubles domainC = new fflib_Doubles((List<Object>) dataList);
System.assert(domainA.getDoubleSet().containsAll(domainB.getDoubles())); System.assert(domainA.getDoubleSet().containsAll(domainB.getDoubles()));
System.assert(domainA.getDoubleSet().containsAll(domainC.getDoubles())); System.assert(domainA.getDoubleSet().containsAll(domainC.getDoubles()));
@@ -119,9 +119,9 @@ private class PrimitiveDomainsTest
fflib_IDGenerator.generate(Schema.Account.SObjectType) fflib_IDGenerator.generate(Schema.Account.SObjectType)
}; };
Ids domainA = new Ids(dataSet); fflib_Ids domainA = new fflib_Ids(dataSet);
Ids domainB = new Ids(new List<Id>(dataSet)); fflib_Ids domainB = new fflib_Ids(new List<Id>(dataSet));
Ids domainC = new Ids((List<Object>) new List<Id>(dataSet)); fflib_Ids domainC = new fflib_Ids((List<Object>) new List<Id>(dataSet));
System.assert(domainA.getIds().containsAll(domainB.getIdList())); System.assert(domainA.getIds().containsAll(domainB.getIdList()));
System.assert(domainA.getIds().containsAll(domainC.getIdList())); System.assert(domainA.getIds().containsAll(domainC.getIdList()));
@@ -138,7 +138,7 @@ private class PrimitiveDomainsTest
fflib_IDGenerator.generate(Schema.Account.SObjectType) fflib_IDGenerator.generate(Schema.Account.SObjectType)
})); }));
Ids domainA = new Ids(data); fflib_Ids domainA = new fflib_Ids(data);
System.assert(domainA.getIds().containsAll((List<Id>) data.getObjects())); System.assert(domainA.getIds().containsAll((List<Id>) data.getObjects()));
} }
@@ -148,9 +148,9 @@ private class PrimitiveDomainsTest
{ {
final Set<Integer> dataSet = new Set<Integer> {1261, 31415}; final Set<Integer> dataSet = new Set<Integer> {1261, 31415};
Integers domainA = new Integers(dataSet); fflib_Integers domainA = new fflib_Integers(dataSet);
Integers domainB = new Integers(new List<Integer>(dataSet)); fflib_Integers domainB = new fflib_Integers(new List<Integer>(dataSet));
Integers domainC = new Integers((List<Object>) new List<Integer>(dataSet)); fflib_Integers domainC = new fflib_Integers((List<Object>) new List<Integer>(dataSet));
System.assert(domainA.getIntegerSet().containsAll(domainB.getIntegers())); System.assert(domainA.getIntegerSet().containsAll(domainB.getIntegers()));
System.assert(domainA.getIntegerSet().containsAll(domainC.getIntegers())); System.assert(domainA.getIntegerSet().containsAll(domainC.getIntegers()));
@@ -161,9 +161,9 @@ private class PrimitiveDomainsTest
{ {
final Set<Long> dataSet = new Set<Long> {1261, 31415}; final Set<Long> dataSet = new Set<Long> {1261, 31415};
Longs domainA = new Longs(dataSet); fflib_Longs domainA = new fflib_Longs(dataSet);
Longs domainB = new Longs(new List<Long>(dataSet)); fflib_Longs domainB = new fflib_Longs(new List<Long>(dataSet));
Longs domainC = new Longs((List<Object>) new List<Long>(dataSet)); fflib_Longs domainC = new fflib_Longs((List<Object>) new List<Long>(dataSet));
System.assert(domainA.getLongSet().containsAll(domainB.getLongs())); System.assert(domainA.getLongSet().containsAll(domainB.getLongs()));
System.assert(domainA.getLongSet().containsAll(domainC.getLongs())); System.assert(domainA.getLongSet().containsAll(domainC.getLongs()));
@@ -174,9 +174,9 @@ private class PrimitiveDomainsTest
{ {
final Set<String> dataSet = new Set<String> {'Hello', 'World'}; final Set<String> dataSet = new Set<String> {'Hello', 'World'};
Strings domainA = new Strings(dataSet); fflib_Strings domainA = new fflib_Strings(dataSet);
Strings domainB = new Strings(new List<String>(dataSet)); fflib_Strings domainB = new fflib_Strings(new List<String>(dataSet));
Strings domainC = new Strings((List<Object>) new List<String>(dataSet)); fflib_Strings domainC = new fflib_Strings((List<Object>) new List<String>(dataSet));
System.assert(domainA.getStringSet().containsAll(domainB.getStrings())); System.assert(domainA.getStringSet().containsAll(domainB.getStrings()));
System.assert(domainA.getStringSet().containsAll(domainC.getStrings())); System.assert(domainA.getStringSet().containsAll(domainC.getStrings()));
@@ -211,7 +211,7 @@ private class SObjectsTest
static void itShouldReturnRecordsById() static void itShouldReturnRecordsById()
{ {
final Id idA = fflib_IDGenerator.generate(Schema.Account.SObjectType); final Id idA = fflib_IDGenerator.generate(Schema.Account.SObjectType);
final Ids ids = new Ids(new Set<Id> {idA}); final fflib_Ids ids = new fflib_Ids(new Set<Id> {idA});
DomainAccounts domain = new DomainAccounts( DomainAccounts domain = new DomainAccounts(
new List<Account> new List<Account>
{ {
@@ -336,7 +336,7 @@ private class SObjectsTest
} }
private class DomainAccounts extends SObjects private class DomainAccounts extends fflib_SObjects2
{ {
public DomainAccounts(List<SObject> records) public DomainAccounts(List<SObject> records)
{ {