OptionalSObject
A container object which may or may not contain a non-null SObject
record. If a record is present, isPresent()
will return true and get()
will return the record. Additional methods that depend on the presence or absence of a contained record are provided, such as orElse()
(return a default record if record not present) or orElseThrow
(throw an exception if a record is not present).
#
ofBuilds an OptionalSObject
.
#
isPresentReturns true
if a record is present.
Signature
Boolean isPresent()
#
getReturns the record when it is present. Throws a System.NoSuchElementException
when it is not.
Signature
SObject get()
#
orElseReturns a record when it is present, or other
when it is not.
Signature
SObject orElse(SObject other)
#
orElseThrowReturns a record when it is present, or throws e
when it is not.
Signature
SObject orElseThrow(Exception e)