@NonNull open static fun <R : Any!> ofNullable(@Nullable value: R?): Try<R>
Creates a Try
from a given value. If the value is null a Failure
will be created containing information about a NullPointerException
.
value
- R?: From this value a Success
will be created, if the value is null a Failure
will be returned.
Return
Try<R>: instance of Success
or Failure
if value is null.
@NonNull open static fun <R : Any!> ofNullable(@Nullable value: R?, exception: Exception!): Try<R>
Creates a Try
from a given value. If the value is null a Failure
will be created with provided exception.
value
- R?: From this value a Success
will be created, if the value is null a Failure
will be returned.
exception
- Exception!: From this Exception
a Failure
will be created.
Return
Try<R>: instance of Success
or Failure
if value is null.