public class Try<A>
Representation of an operation that has either succeeded with a result (represented by class Try.Success) or failed with an
exception (represented by class Try.Failure).
class Try.Success,
class Try.Failurepublic boolean isFailure()
Returns true iff the class Try is a class Try.Success.
class Try,
class Try.Successpublic boolean isSuccess()
Returns true iff the class Try is a class Try.Failure.
class Try,
class Try.Failurepublic A getOrThrow()
Returns the value if a class Try.Success otherwise throws the exception if a class Try.Failure.
class Try.Success,
class Try.Failure@NotNull public Try<A> throwError()
If this is a class Try.Failure wrapping an Error then throw it, otherwise return this for chaining.
class Try.Failure,
Error@NotNull public <B> Try<B> map(@NotNull kotlin.jvm.functions.Function1<? super A,? extends B> function)
Maps the given function to the value from this class Try.Success, or returns this if this is a class Try.Failure.
class Try.Success,
class Try.Failure@NotNull public <B> Try<B> flatMap(@NotNull kotlin.jvm.functions.Function1<? super A,? extends net.corda.core.utilities.Try<? extends B>> function)
Returns the given function applied to the value from this class Try.Success, or returns this if this is a class Try.Failure.
class Try.Success,
class Try.Failure@NotNull public <B,C> Try<C> combine(@NotNull Try<? extends B> other, @NotNull kotlin.jvm.functions.Function2<? super A,? super B,? extends C> function)
Maps the given function to the values from this class Try.Success and other, or returns this if this is a class Try.Failure
or other if other is a class Try.Failure.
class Try.Success,
other,
class Try.Failure,
other,
other,
class Try.Failure@NotNull public Try<A> doOnSuccess(@NotNull java.util.function.Consumer<? super A> action)
Applies the given action to the value if class Try.Success, or does nothing if class Try.Failure. Returns this for chaining.
class Try.Success,
class Try.Failure@NotNull public Try<A> doOnFailure(@NotNull java.util.function.Consumer<java.lang.Throwable> action)
Applies the given action to the error if class Try.Failure, or does nothing if class Try.Success. Returns this for chaining.
class Try.Failure,
class Try.Success@JvmStatic @NotNull public static <T> Try<T> on(@NotNull kotlin.jvm.functions.Function0<? extends T> body)
Executes the given block of code and returns a class Try.Success capturing the result, or a class Try.Failure if a Throwable is thrown.
It is recommended this be chained with throwError to ensure critial Errors are thrown and not captured.
class Try.Success,
class Try.Failure,
Throwable,
throwError,
Error