Try.Failure<T>, Try.Success<T>
Modifier and Type | Method and Description |
---|---|
<R> Try<R> |
flatMap(Function<? super T,Try<R>> func)
Maps successful tries through
func , passes failure through as is. |
T |
get()
Returns the value associated with a successful try, or rethrows the exception if the try
failed.
|
Throwable |
getFailure()
Returns the cause of failure for a failed try.
|
boolean |
isSuccess()
Returns try if this is a successful try, false if it is a failed try.
|
<R> Try<R> |
map(Function<? super T,R> func)
Maps successful tries through
func , passees failure through as is. |
Try<T> |
recover(Function<? super Throwable,T> func)
Maps failed tries through
func , passes success through as is. |
String |
toString() |
public final Throwable cause
public Failure(Throwable cause)
public T get()
Try
cause
of
a newly constructed RuntimeException
.public Throwable getFailure()
Try
IllegalStateException
if
called on a successful try.getFailure
in class Try<T>
public boolean isSuccess()
Try
public <R> Try<R> map(Function<? super T,R> func)
Try
func
, passees failure through as is.public Try<T> recover(Function<? super Throwable,T> func)
Try
func
, passes success through as is. Note: if func
throws an exception, you will get back a failure try with the new failure. Ideally one
could generalize the type T
here but Java doesn't allow type parameters with lower
bounds.public <R> Try<R> flatMap(Function<? super T,Try<R>> func)
Try
func
, passes failure through as is.Copyright © 2017. All rights reserved.