Package org.javimmutable.collections
Class Result.Failure<T>
java.lang.Object
org.javimmutable.collections.Result<T>
org.javimmutable.collections.Result.Failure<T>
-
Nested Class Summary
Nested classes/interfaces inherited from class org.javimmutable.collections.Result
Result.Failure<T>, Result.Success<T>
-
Method Summary
Modifier and TypeMethodDescriptionapply
(Proc1Throws<T, ? super Exception> proc) Does nothing if we are a failure result.boolean
<U> Result
<U> Replaces our successful result with a new value computed using the provided function.flatMapFailure
(Func1Throws<Exception, Result<T>, Exception> func) Replaces our failure result with a new value computed using the provided function.get()
Gets the value or throws the exception.int
hashCode()
<U> Result
<U> map
(Func1Throws<T, U, Exception> func) Replaces our successful result with a new value computed using the provided function.mapFailure
(Func1Throws<Exception, T, Exception> func) Replaces our failure result with a new value computed using the provided function.Converts a failure result into a success result with a specified value.Converts a failure result into a success result with the value returned by aSupplier
.
-
Method Details
-
get
Description copied from class:Result
Gets the value or throws the exception. Used to unwrap the result so it can be handled using try/catch. -
orElse
Description copied from class:Result
Converts a failure result into a success result with a specified value. If we are a failure result return a success result containing the specified value. Otherwise return this. -
orElseGet
Description copied from class:Result
Converts a failure result into a success result with the value returned by aSupplier
. If we are a failure result return a success result containing the value returned by theSupplier
. Otherwise return this. Does not capture any runtime exception thrown by the supplier. -
map
Description copied from class:Result
Replaces our successful result with a new value computed using the provided function. Simply returns this if we are a failure result. -
flatMap
Description copied from class:Result
Replaces our successful result with a new value computed using the provided function. Simply returns this if we are a failure result. -
mapFailure
Description copied from class:Result
Replaces our failure result with a new value computed using the provided function. Simply returns this if we are a success result.- Specified by:
mapFailure
in classResult<T>
-
flatMapFailure
Description copied from class:Result
Replaces our failure result with a new value computed using the provided function. Simply returns this if we are a success result.- Specified by:
flatMapFailure
in classResult<T>
-
apply
Description copied from class:Result
Does nothing if we are a failure result. Calls a function with our value if we are a success result. If the function throws an exception returns a new failure result containing that exception. Otherwise returns this. -
equals
-
hashCode
public int hashCode()
-