T
- The type of the exception represented by this instancepublic final class Failure<T> extends Object implements Try<T>, Serializable
Try
. Try
.Constructor and Description |
---|
Failure(Throwable throwable)
Creates a Failure for the provided Throwable.
|
Modifier and Type | Method and Description |
---|---|
Try<Throwable> |
failed()
|
Try<T> |
filter(java.util.function.Predicate<T> predicate)
Always returns this.
|
<R> Try<R> |
flatMap(java.util.function.Function<T,Try<R>> function)
Always returns this.
|
T |
get()
Always throws the
Throwable this instance represents. |
T |
getOrElse(java.util.function.Supplier<T> supplier)
Always returns the value provided by the supplier.
|
boolean |
isSuccess()
Always returns
false . |
Iterator<T> |
iterator()
Always returns an empty iterator.
|
<R> Try<R> |
map(java.util.function.Function<T,R> function)
Always returns this.
|
Try<T> |
orElse(java.util.function.Supplier<Try<T>> supplier)
Always returns the value provided by the supplier.
|
Try<T> |
recover(java.util.function.Function<Throwable,T> function)
|
Try<T> |
recoverWith(java.util.function.Function<Throwable,Try<T>> function)
Applies the provided function to the Throwable of this
Failure and returns the result. |
java.util.stream.Stream<T> |
stream()
Always returns an empty stream.
|
String |
toString()
Returns a String representation of the instance.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
apply, apply, asOption, isFailure, iterator, orNull, stream
forEach, spliterator
public Failure(Throwable throwable)
throwable
- The throwablepublic boolean isSuccess()
false
.public T getOrElse(java.util.function.Supplier<T> supplier)
public Try<T> orElse(java.util.function.Supplier<Try<T>> supplier)
public T get() throws Throwable
Throwable
this instance represents. public <R> Try<R> map(java.util.function.Function<T,R> function)
public <R> Try<R> flatMap(java.util.function.Function<T,Try<R>> function)
public Try<T> filter(java.util.function.Predicate<T> predicate)
public Try<T> recover(java.util.function.Function<Throwable,T> function)
public Try<T> recoverWith(java.util.function.Function<Throwable,Try<T>> function)
Failure
and returns the result.recoverWith
in interface Try<T>
function
- The function to apply in case of a Failure
public String toString()
public final Iterator<T> iterator()
public final java.util.stream.Stream<T> stream()
Copyright © 2016, Peter Nerg Apache License v2.0