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.Failure
Modifier and Type | Class and Description |
---|---|
static class |
Try.Companion |
static class |
Try.Failure<A> |
static class |
Try.Success<A> |
Modifier and Type | Field and Description |
---|---|
static Try.Companion |
Companion |
Modifier and Type | Method and Description |
---|---|
<B,C> Try<C> |
combine(Try<? extends B> other,
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 . |
Try<A> |
doOnFailure(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. |
Try<A> |
doOnSuccess(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. |
<B> Try<B> |
flatMap(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 . |
A |
getOrThrow()
Returns the value if a
class Try.Success otherwise throws the exception if a class Try.Failure . |
boolean |
isFailure()
|
boolean |
isSuccess()
|
<B> Try<B> |
map(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 . |
Try<A> |
throwError()
|
public static Try.Companion Companion
public boolean isFailure()
Returns true
iff the class Try
is a class Try.Success
.
class Try
,
class Try.Success
public boolean isSuccess()
Returns true
iff the class Try
is a class Try.Failure
.
class Try
,
class Try.Failure
public 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
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
,
Errorpublic <B> Try<B> map(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
public <B> Try<B> flatMap(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
public <B,C> Try<C> combine(Try<? extends B> other, 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
,
class Try.Failure
,
class Try.Failure
public Try<A> doOnSuccess(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
public Try<A> doOnFailure(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