Skip to main content

SObjectNotNull

SObjectNotNull implements SObjectPredicate and returns true when the given SObject is not null.

Usage

SObjectNotNull is available as a static instance on Fn and can be used directly:

// Filter out null records
List<Account> accounts = new List<Account>{acc1, null, acc2};
SObjectCollection nonNull = SObjectCollection.of(accounts).filter(Fn.NotNull);

// Use in conditional logic
if (Fn.NotNull.call(myAccount)) {
// Process account
}