Try.Transformer<S,T>| Modifier and Type | Method and Description |
|---|---|
<U> Try<U> |
andThen(java.util.function.Function<V,Try<U>> function)
If this
Try is a success, apply the supplied function to its
value and return the resulting Try; if this Try is a
failure, do nothing. |
<U> Try<U> |
andThenTry(Try.Transformer<V,U> transformer)
If this
Try is a success, apply the supplied transformer to its
value and return a new successful or failed Try depending on the
transformer's outcome; if this Try is a failure, do nothing. |
boolean |
equals(java.lang.Object that) |
V |
get()
If this
Try is a success, get the contained value; if this
Try is a failure, throw the contained exception. |
<E extends java.lang.Exception> |
getOrThrow(java.util.function.Function<? super java.lang.Exception,E> exceptionTransformer)
If this
Try is a success, get the contained value; if this
Try is a failure, call the supplied Function with the
contained exception and throw the resulting Exception. |
int |
hashCode() |
Try<V> |
ifFailure(java.util.function.Consumer<java.lang.Exception> causeConsumer)
If this
Try is a failure, call the supplied Consumer with
the contained exception; otherwise, do nothing. |
Try<V> |
ifSuccess(java.util.function.Consumer<V> valueConsumer)
If this
Try is a success, call the supplied Consumer with
the contained value; otherwise, do nothing. |
Try<V> |
orElse(java.util.function.Supplier<Try<V>> supplier)
If this
Try is a failure, call the supplied supplier and return
the resulting Try; if this Try is a success, do nothing. |
Try<V> |
orElseTry(java.util.concurrent.Callable<V> action)
If this
Try is a failure, call the supplied action and return a
new successful or failed Try depending on the action's outcome;
if this Try is a success, do nothing. |
java.util.Optional<V> |
toOptional()
If this
Try is a failure, return an empty Optional; if
this Try is a success, wrap the contained value using
Optional.ofNullable(Object). |
private final V value
Success(V value)
public <U> Try<U> andThenTry(Try.Transformer<V,U> transformer)
TryTry is a success, apply the supplied transformer to its
value and return a new successful or failed Try depending on the
transformer's outcome; if this Try is a failure, do nothing.andThenTry in class Try<V>transformer - the transformer to try; must not be nullTry; never nullpublic <U> Try<U> andThen(java.util.function.Function<V,Try<U>> function)
TryTry is a success, apply the supplied function to its
value and return the resulting Try; if this Try is a
failure, do nothing.public Try<V> orElseTry(java.util.concurrent.Callable<V> action)
TryTry is a failure, call the supplied action and return a
new successful or failed Try depending on the action's outcome;
if this Try is a success, do nothing.public Try<V> orElse(java.util.function.Supplier<Try<V>> supplier)
TryTry is a failure, call the supplied supplier and return
the resulting Try; if this Try is a success, do nothing.public V get()
TryTry is a success, get the contained value; if this
Try is a failure, throw the contained exception.public <E extends java.lang.Exception> V getOrThrow(java.util.function.Function<? super java.lang.Exception,E> exceptionTransformer)
TryTry is a success, get the contained value; if this
Try is a failure, call the supplied Function with the
contained exception and throw the resulting Exception.getOrThrow in class Try<V>exceptionTransformer - the transformer to be called with the
contained exception, if available; must not be nullpublic Try<V> ifSuccess(java.util.function.Consumer<V> valueConsumer)
TryTry is a success, call the supplied Consumer with
the contained value; otherwise, do nothing.public Try<V> ifFailure(java.util.function.Consumer<java.lang.Exception> causeConsumer)
TryTry is a failure, call the supplied Consumer with
the contained exception; otherwise, do nothing.public java.util.Optional<V> toOptional()
TryTry is a failure, return an empty Optional; if
this Try is a success, wrap the contained value using
Optional.ofNullable(Object).toOptional in class Try<V>Optional; never null but potentially
emptypublic boolean equals(java.lang.Object that)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Object