Add method overload for getIdFieldValues to omit null values

This commit is contained in:
Wim Velzeboer
2024-04-10 10:28:59 +01:00
parent 64559fdbe5
commit 273e47f0db
2 changed files with 33 additions and 4 deletions
@@ -657,6 +657,26 @@ public virtual class fflib_SObjects2
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 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;
}
@TestVisible
protected virtual List<SObject> getRecordsIsNot(Schema.SObjectField sObjectField, Id idValue)
{
return getRecordsNotIn(sObjectField, new Set<Id>{ idValue });
}
@TestVisible
protected virtual List<SObject> getRecordsNotIn(Schema.SObjectField sObjectField, Set<Id> idValues)
{
List<SObject> result = new List<SObject>();