BindResult<T> class final

The outcome of Binder.bind: the value, or the fact that no property was set.

A property that is not set is different from one set to an empty value, and the caller usually wants a default for the first case. The methods here say what to do then: use a default (orElse, orElseGet), fail (orElseThrow, get) or do nothing (ifBound).

final port = Binder.get(environment)
    .bind('app.port', const ClassType<int>())
    .orElse(8080);

Spring (Java): BindResult, with the same methods.

Properties

hashCode → int
The hash code for this object.
no setterinherited
isBound → bool
Whether at least one property was found and bound. A value can be bound and still be null.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

get() → T
The bound value. Throws a StateError when nothing was bound; use it when the property is known to be set.
ifBound(void action(T value)) → void
Calls action with the bound value; does nothing when nothing was bound.
map<R>(R mapper(T value)) → BindResult<R>
A result holding the bound value transformed by mapper. When nothing was bound, mapper is not called and the result stays unbound.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
orElse(T other) → T
The bound value, or the default other when nothing was bound.
orElseGet(T other()) → T
The bound value, or the result of other when nothing was bound. other is only called then, so it suits a default that is costly to build.
orElseThrow(Object error()) → T
The bound value; when nothing was bound, throws what error returns. Use it for a required setting, with a message that says what to set.
toString() → String
A string representation of this object.
inherited

Operators

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