T - The type of the value represented by this Optionpublic interface Try<T> extends Iterable<T>
Success or Failure.| Modifier and Type | Method and Description |
|---|---|
static <T> Try<T> |
apply(T value)
|
default Option<T> |
asOption()
|
Try<Throwable> |
failed()
|
<R> Try<R> |
flatMap(java.util.function.Function<T,Try<R>> function)
|
T |
get()
|
T |
getOrElse(java.util.function.Supplier<T> supplier)
|
default boolean |
isFailure()
|
boolean |
isSuccess()
|
default Iterator<T> |
iterator()
|
<R> Try<R> |
map(java.util.function.Function<T,R> function)
|
Try<T> |
orElse(java.util.function.Supplier<Try<T>> supplier)
|
default T |
orNull()
Returns the value if it is a
Success, else null. |
default java.util.stream.Stream<T> |
stream()
|
forEach, spliteratorstatic <T> Try<T> apply(T value)
null or non-throwable value is provided then Success is returned containing the value, else Failure containing the
provided throwable.T - The type for the Tryvalue - The value for this to create a Trydefault boolean isFailure()
Failureboolean isSuccess()
SuccessT getOrElse(java.util.function.Supplier<T> supplier)
supplier - The supplier to return the value in case of a Failuredefault T orNull()
Success, else null.null.Try<T> orElse(java.util.function.Supplier<Try<T>> supplier)
supplier - The supplier to return the value in case of a Failure<R> Try<R> map(java.util.function.Function<T,R> function)
R - The type for the return value from the functionfunction - The function to use<R> Try<R> flatMap(java.util.function.Function<T,Try<R>> function)
R - The type for the return value from the functionfunction - The function to usedefault java.util.stream.Stream<T> stream()
Success, or an empty Stream if it is a Failure.Success containing a null value then the stream will also be empty.Copyright © 2015. All rights reserved.