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

getOrElse

abstract fun getOrElse(@Nullable defaultValue: T?): T

Returns success value or in case of failure returns the passed value.

Parameters

defaultValue - T?: This value will be returned in case of Failure.

Return
T: Value stored in the Success or value passed to this method in case of Failure.

open fun getOrElse(@NonNull provider: (in Throwable!) -> T): T

Returns Success value or in case of Failure throws exception that can be built by the given function from the throwable stored in the Failure.

Parameters

provider - (in Throwable!) -> T: function for converting Exception stored in Failure into the desired value.

Return
T: value stored in the Success