public class Failure<T> extends Try<T>
| 限定符和类型 | 方法和说明 |
|---|---|
Try<Exception> |
failed()
Inverts this `Try`.
|
Try<T> |
filter(java.util.function.Predicate<T> p)
Converts this to a `Failure` if the predicate is not satisfied.
|
<U> Try<U> |
flatMap(java.util.function.Function<T,Try<U>> f)
Returns the given function applied to the value from this `Success` or returns this if this is a `Failure`.
|
Try<T> |
foreach(java.util.function.Consumer<T> f)
Applies the given function `f` if this is a `Success`, otherwise returns `Unit` if this is a `Failure`.
|
T |
get()
Returns the value from this `Success` or throws the exception if this is a `Failure`.
|
boolean |
isFailure()
Returns `true` if the `Try` is a `Failure`, `false` otherwise.
|
boolean |
isSuccess()
Returns `true` if the `Try` is a `Success`, `false` otherwise.
|
<U> Try<U> |
map(java.util.function.Function<T,U> f)
Maps the given function to the value from this `Success` or returns this if this is a `Failure`.
|
Try<T> |
onException(java.util.function.Consumer<Exception> f) |
Try<T> |
recover(java.util.function.Function<Exception,T> f)
Applies the given function `f` if this is a `Failure`, otherwise returns this if this is a `Success`.
|
Try<T> |
recoverWith(java.util.function.Function<Exception,Try<T>> f)
Applies the given function `f` if this is a `Failure`, otherwise returns this if this is a `Success`.
|
<U> Try<U> |
transform(java.util.function.Function<T,Try<U>> s,
java.util.function.Function<Exception,Try<U>> f)
Completes this `Try` by applying the function `f` to this if this is of type `Failure`, or conversely, by applying
`s` if this is a `Success`.
|
public boolean isFailure()
Trypublic boolean isSuccess()
Trypublic T get()
Trypublic Try<T> foreach(java.util.function.Consumer<T> f)
Try''Note:'' If `f` throws, then this method may throw an exception.
public <U> Try<U> flatMap(java.util.function.Function<T,Try<U>> f)
Trypublic <U> Try<U> map(java.util.function.Function<T,U> f)
Trypublic Try<T> filter(java.util.function.Predicate<T> p)
Trypublic Try<T> recoverWith(java.util.function.Function<Exception,Try<T>> f)
TryrecoverWith 在类中 Try<T>public Try<T> recover(java.util.function.Function<Exception,T> f)
Trypublic Try<Exception> failed()
Trypublic <U> Try<U> transform(java.util.function.Function<T,Try<U>> s, java.util.function.Function<Exception,Try<U>> f)
Trypublic Try<T> onException(java.util.function.Consumer<Exception> f)
onException 在类中 Try<T>Copyright © 2017. All rights reserved.