Opt<T> class

Optional type wrapper for Zorphy

Properties

hashCode int
The hash code for this object.
no setterinherited
isEmpty bool
Returns true when the wrapped value is null.
no setter
isPresent bool
Returns true when a non-null value is present.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
value → T?
Returns the wrapped value, or null if empty.
no setter

Methods

ifPresent(void consumer(T value)) → void
Executes consumer when a value is present.
map<U>(U mapper(T value)) Opt<U>
Maps the value to a new Opt, preserving emptiness.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
orElse(T other) → T
Returns the value or a fallback when empty.
orElseGet(T supplier()) → T
Returns the value or computes a fallback when empty.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

empty<T>() Opt<T>
Creates an empty Opt with no value.
of<T>(T value) Opt<T>
Wraps a non-null value in an Opt.
ofNullable<T>(T? value) Opt<T>
Wraps a nullable value in an Opt.