Optional<T>

v1.0

Description


The Optional<T> is a wrapper for read operations to handle cases where the query result may be null.

Properties


NameDescription
HasValueIndicates whether the current Optional<T> object has a value or not.
ValueGets the value of the current Optional<T> object.

Constructors


NameDescriptionParameters
Of(value)Creates a new Optional<T> object with the specified value.value: The value to wrap.
OfNullable(value)Creates a new Optional<T> object with the specified value.value: The value to wrap.

Methods

NameDescriptionParameters
OrElse(fallback)Returns the value of the current Optional<T> object, or the specified fallback value if the current object has no value.fallback: The fallback value.
OrElseThrow(exceptionSupplier)Returns the value of the current Optional<T> object, or throws the specified exception if the current object has no value.exceptionSupplier: A Func<Exception> that returns the exception to throw.
IfNullThen(callbackAction)Executes the specified action if the current Optional<T> object has no value.callbackAction: The action to execute.