Try.Transformer<S,T>
Modifier and Type | Field and Description |
---|---|
private java.lang.Exception |
cause |
Constructor and Description |
---|
Failure(java.lang.Exception cause) |
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 <U> Try<U> |
uncheckedCast() |
public <U> Try<U> andThenTry(Try.Transformer<V,U> transformer)
Try
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.andThenTry
in class Try<V>
transformer
- the transformer to try; must not be null
Try
; never null
public <U> Try<U> andThen(java.util.function.Function<V,Try<U>> function)
Try
Try
is a success, apply the supplied function to its
value and return the resulting Try
; if this Try
is a
failure, do nothing.private <U> Try<U> uncheckedCast()
public Try<V> orElseTry(java.util.concurrent.Callable<V> action)
Try
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.public Try<V> orElse(java.util.function.Supplier<Try<V>> supplier)
Try
Try
is a failure, call the supplied supplier and return
the resulting Try
; if this Try
is a success, do nothing.public V get() throws java.lang.Exception
Try
Try
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) throws E extends java.lang.Exception
Try
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
.getOrThrow
in class Try<V>
exceptionTransformer
- the transformer to be called with the
contained exception, if available; must not be null
E
- if this Try
is a failureE extends java.lang.Exception
public Try<V> ifSuccess(java.util.function.Consumer<V> valueConsumer)
Try
Try
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)
Try
Try
is a failure, call the supplied Consumer
with
the contained exception; otherwise, do nothing.public java.util.Optional<V> toOptional()
Try
Try
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.Object
public int hashCode()
hashCode
in class java.lang.Object