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
Methods
-
get(
) → T -
The bound value. Throws a
StateErrorwhen nothing was bound; use it when the property is known to be set. -
ifBound(
void action(T value)) → void -
Calls
actionwith 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,mapperis 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
otherwhen nothing was bound. -
orElseGet(
T other()) → T -
The bound value, or the result of
otherwhen nothing was bound.otheris 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
errorreturns. 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