map<R> method

  1. @override
ResourceTry<R> map<R>(
  1. R transform(
    1. SuccessT value
    )
)
override

Returns the encapsulated result of the given transform function applied to the encapsulated value if this instance represents success or the original encapsulated Throwable exception if it is failure.

Implementation

@override
ResourceTry<R> map<R>(R Function(SuccessT value) transform) {
  if (isSuccess) {
    return ResourceTry.success(transform(getOrThrow()));
  } else {
    return ResourceTry.failure(exceptionOrNull()!);
  }
}