Maybe<T> class abstract

A variation of the Maybe monad with eager execution.

Constructors

Maybe()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

as<R>() Maybe<R>
WARNING! This method is experimental and may be removed in the future versions. Forceful typecast to R.
chain(Maybe<T> next) Maybe<T>
If this is Nothing, returns next. Otherwise return this..
fallback(Maybe<T> next()) Maybe<T>
If this is Nothing, returns the result of next. Otherwise return this..
flatMap<P>(Maybe<P> mapper(T value)) Maybe<P>
Maps the value to P.
ifNothing(void callback()) Maybe<T>
Calls the callback function if the wrapped value is not present.
ifPresent(void consumer(T value)) Maybe<T>
Calls the consumer if the wrapped value is present.
map<P>(P mapper(T value)) Maybe<P>
Maps the value to P.
merge<R, V>(Maybe<V> other, Merger<R, T, V> merger) Maybe<R>
If this and the other are both Just values, merges them using the merger function and returns Just
merge2<R, V1, V2>(Maybe<V1> v1, Maybe<V2> v2, Merger2<R, T, V1, V2> merger) Maybe<R>
Same as merge, but with 2 arguments.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
or(T defaultValue) → T
Returns the wrapped value (if present), or the defaultValue.
orAsync(Future<T> defaultValue) Future<T>
Returns a Future of the wrapped value (if present), or the defaultValue.
orGet(T producer()) → T
Returns the wrapped value (if present), or the result of the producer.
orGetAsync(Future<T> producer()) Future<T>
Returns a Future of the wrapped value (if present), or the result of the producer.
orThrow(Object producer()) → T
Returns the wrapped value (if present), or throws the result of the producer.
toString() String
A string representation of this object.
inherited
tryMap<P>(P mapper(T value)) Maybe<P>
Tries to map value to P. If the mapper throws anything (not just an Exception), returns Nothing<P>.
type<P>() Maybe<P>
Narrows the type to P if the value is present and has actually the type of P.
where(bool predicate(T value)) Maybe<T>
Filter the value using the predicate.

Operators

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