Failure<S extends Object, F extends Object> class
Error Result.
return it when the result of a Result is not the expected value.
- Implemented types
-
- Result<
S, F>
- Result<
- Annotations
-
- @immutable
Constructors
- Failure(F _failure)
-
Receives the
F
param as the error result.const
Properties
- hashCode → int
-
The hash code for this object.
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
exceptionOrNull(
) → F -
Returns the value of Failure or null.
override
-
flatMap<
W extends Object> (Result< W, F> fn(S success)) → Result<W, F> -
Returns a new
Result
, mapping anySuccess
value using the given transformation and unwrapping the producedResult
.override -
flatMapError<
W extends Object> (Result< S, W> fn(F failure)) → Result<S, W> -
Returns a new
Result
, mapping anyError
value using the given transformation and unwrapping the producedResult
.override -
fold<
W> (W onSuccess(S succcess), W onFailure(F failure)) → W -
Returns the result of onSuccess for the encapsulated value
if this instance represents
Success
or the result of onError function for the encapsulated value if it isFailure
.override -
getOrDefault(
S defaultValue) → S -
Returns the encapsulated value if this instance represents
Success
or thedefaultValue
if it isFailure
.override -
getOrElse(
S onFailure(F failure)) → S -
Returns the encapsulated value if this instance represents
Success
or the result ofonFailure
function for the encapsulated aFailure
value.override -
getOrNull(
) → S? -
Returns the value of Success or null.
override
-
getOrThrow(
) → S -
Returns the success value as a throwing expression.
override
-
isError(
) → bool -
Returns true if the current result is an Failure.
override
-
isSuccess(
) → bool -
Returns true if the current result is a Success.
override
-
map<
W extends Object> (W fn(S success)) → Result< W, F> -
Returns a new
Result
, mapping anySuccess
value using the given transformation.override -
mapError<
W extends Object> (W fn(F failure)) → Result< S, W> -
Returns a new
Result
, mapping anyError
value using the given transformation.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onFailure(
void onFailure(F failure)) → Result< S, F> -
Performs the given action on the encapsulated Throwable
exception if this instance represents failure.
Returns the original Result unchanged.
override
-
onSuccess(
void onSuccess(S success)) → Result< S, F> -
Performs the given action on the encapsulated value if this
instance represents success. Returns the original Result unchanged.
override
-
pure<
W extends Object> (W success) → Result< W, F> -
Change the Success value.
override
-
pureError<
W extends Object> (W error) → Result< S, W> -
Change the Failure value.
override
-
recover<
R extends Object> (Result< S, R> onFailure(F failure)) → Result<S, R> -
Returns the encapsulated
Result
of the given transform function applied to the encapsulated aFailure
or the original encapsulated value if it is success.override -
swap(
) → Result< F, S> -
Swap the values contained inside the Success and Failure
of this Result.
override
-
toAsyncResult(
) → AsyncResult< S, F> -
Return a AsyncResult.
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override