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

onBoth

@NonNull abstract fun <R : Any!> onBoth(@NonNull other: Try<out R>, @NonNull action: Consumer2<in T, in R>): Try<T>

Performs the provided action if both current and other Try represents a success. Note: If action throws, then this method may throw an Exception.

Parameters

other - Try<out R>: holds value that will be used in provided action

action - Consumer2<in T, in R>: A side-effect action to perform.

- type of the value wrapped in the other Try

Return
Try<T>: new composed Try.

@NonNull abstract fun <R : Any!> onBoth(@NonNull otherSupplier: Supplier<Try<R>!>, @NonNull action: Consumer2<in T, in R>): Try<T>

Performs the provided action if both current and other supplied Try represents a success. Note: If action throws, then this method may throw an Exception.

Parameters

otherSupplier - Supplier<Try<R>!>: supplies Try that holds value that will be used in provided action

action - Consumer2<in T, in R>: A side-effect action to perform.

- type of the value wrapped in the other Try

Return
Try<T>: new composed Try.