Add method overload for getIdFieldValues to omit null values
This commit is contained in:
@@ -657,6 +657,26 @@ public virtual class fflib_SObjects2
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the Id values, but with the option to omit null values
|
||||||
|
*
|
||||||
|
* @param field The Schema.SObjectField to get their Id values
|
||||||
|
* @param omitNulls If set to TRUE, null values will be removed from the result
|
||||||
|
*
|
||||||
|
* @return The Id values of the given sObjectField, null values are omitted
|
||||||
|
*/
|
||||||
|
@TestVisible
|
||||||
|
protected Set<Id> getIdFieldValues(Schema.SObjectField field, Boolean omitNulls)
|
||||||
|
{
|
||||||
|
Set<Id> result = getIdFieldValues(field);
|
||||||
|
|
||||||
|
if (omitNulls)
|
||||||
|
{
|
||||||
|
result.remove(null);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param sObjectField The Schema.SObjectField to get their Id values
|
* @param sObjectField The Schema.SObjectField to get their Id values
|
||||||
* @param criteria The criteria condition that must be met to include the value in the return
|
* @param criteria The criteria condition that must be met to include the value in the return
|
||||||
@@ -791,11 +811,13 @@ public virtual class fflib_SObjects2
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestVisible
|
||||||
protected virtual List<SObject> getRecordsIsNot(Schema.SObjectField sObjectField, Id idValue)
|
protected virtual List<SObject> getRecordsIsNot(Schema.SObjectField sObjectField, Id idValue)
|
||||||
{
|
{
|
||||||
return getRecordsNotIn(sObjectField, new Set<Id>{ idValue });
|
return getRecordsNotIn(sObjectField, new Set<Id>{ idValue });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestVisible
|
||||||
protected virtual List<SObject> getRecordsNotIn(Schema.SObjectField sObjectField, Set<Id> idValues)
|
protected virtual List<SObject> getRecordsNotIn(Schema.SObjectField sObjectField, Set<Id> idValues)
|
||||||
{
|
{
|
||||||
List<SObject> result = new List<SObject>();
|
List<SObject> result = new List<SObject>();
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ private class fflib_SObjects2Test
|
|||||||
domain.getFieldsByField(Account.Id, Account.AnnualRevenue);
|
domain.getFieldsByField(Account.Id, Account.AnnualRevenue);
|
||||||
domain.getFieldByField(Account.Id, Account.Id);
|
domain.getFieldByField(Account.Id, Account.Id);
|
||||||
domain.getIdFieldsByIdField(Account.Id, Account.Id);
|
domain.getIdFieldsByIdField(Account.Id, Account.Id);
|
||||||
domain.getIdFieldsByStringField(Account.Name, Account.Id);
|
domain.getIdFieldsByStringField(Account.Id, Account.Name);
|
||||||
domain.getIdFieldValues(Account.Id);
|
domain.getIdFieldValues(Account.Id);
|
||||||
domain.getIdFieldValues(Account.Id, criteria);
|
domain.getIdFieldValues(Account.Id, criteria);
|
||||||
domain.getDecimalFieldValues(Account.BillingLatitude, criteria);
|
domain.getDecimalFieldValues(Account.BillingLatitude, criteria);
|
||||||
@@ -117,8 +117,16 @@ private class fflib_SObjects2Test
|
|||||||
domain.getSObjectsByStringField(Account.Name);
|
domain.getSObjectsByStringField(Account.Name);
|
||||||
domain.getStringFieldByStringField(Account.Name, Account.AccountNumber);
|
domain.getStringFieldByStringField(Account.Name, Account.AccountNumber);
|
||||||
domain.getStringFieldValues(Account.Name, criteria);
|
domain.getStringFieldValues(Account.Name, criteria);
|
||||||
domain.stri
|
domain.stripInaccessibleFields();
|
||||||
|
domain.getDateFieldValues(Account.CreatedDate);
|
||||||
|
domain.getDateFieldValues(Account.CreatedDate, criteria);
|
||||||
|
domain.getIdFieldValues(Account.Id, criteria);
|
||||||
|
domain.getRecords(Account.Id, domain.getFirstSObject().Id);
|
||||||
|
domain.getRecords(Account.Name, 'A');
|
||||||
|
domain.getRecordsIsNot(Account.Name, 'A');
|
||||||
|
domain.getRecordsIsNot(Account.Id, domain.getFirstSObject().Id);
|
||||||
|
domain.getSObjectByIdField(Account.Id);
|
||||||
|
domain.getIdFieldValues(Account.Id, true);
|
||||||
// todo - add assertions
|
// todo - add assertions
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -462,7 +470,6 @@ private class fflib_SObjects2Test
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@IsTest
|
@IsTest
|
||||||
static void itShouldReturnRecordsIds()
|
static void itShouldReturnRecordsIds()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user