@NonNull open static fun <R : Any!> when(condition: Boolean, @NonNull value: R): Try<R>
Creates a Try
from the given value
. A Success
is returned if the given condition
is met, a Failure
otherwise.
condition
- Boolean: depending on this condition the value may be wrapped in Success
.
value
- R: will get wrapped in Try
if condition is met.
- type of the value wrapped in Try
.
Return
Try<R>: Success
if condition is met, Failure
otherwise.
@NonNull open static fun <R : Any!> when(condition: Boolean, @NonNull supplier: Supplier<out R>): Try<R>
Lazy equivalent of Try#when(boolean, Object)
. Creates a Try
from the value returned by the given Supplier
. A Success
is returned if the given condition
is met, a Failure
otherwise.
condition
- Boolean: depending on this condition the value may be wrapped in Success
.
supplier
- Supplier<out R>: will return a value that will get wrapped in Try
if condition is met.
- type of the value wrapped in Try
.
Return
Try<R>: Success
if condition is met, Failure
otherwise.
open static fun <R : Any!> when(@NonNull conditionSupplier: Supplier<Boolean!>, @NonNull valueSupplier: Supplier<out R>, @NonNull errorSupplier: Supplier<out Throwable!>): Try<R>!