sdk-common / com.tomtom.online.sdk.common.functional / Try / ofNullable

ofNullable

@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.

Parameters

value - R?: From this value a Success will be created, if the value is null a Failure will be returned.

- Type of the stored value.

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.

Parameters

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.

- Type of the stored value.

Return
Try<R>: instance of Success or Failure if value is null.