Try<T> |
Try.filter(UnChecked.CheckedPredicate<? super T> predicate) |
If the Try is a failure, the current Try is returned.
|
Try<T> |
Try.filter(UnChecked.CheckedPredicate<? super T> predicate,
java.util.function.Supplier<? extends java.lang.Throwable> exceptionOnTestFailure) |
If the Try is a failure, the current Try is returned.
|
<U> Try<U> |
Try.flatMap(Try.TryMapper<? super T,Try<? extends U>> flatMapper) |
Like Stream.flatMap(), Try.flatMap flattens two nested Try.
|
static <U> Try<U> |
Try.identity(Try<U> value) |
Identity Try function.
|
Try<java.lang.Void> |
Try.ifError(Try.TryConsumer<? super java.lang.Throwable> consumer) |
If Try is a failure, the provided consumer will be applied to the generated Throwable.
|
Try<java.lang.Void> |
Try.ifSuccess(Try.TryConsumer<? super T> consumer) |
If the Try is a success, the provided consumer is applied to the result.
|
Try<java.lang.Void> |
Try.ifSuccessOrElse(Try.TryConsumer<? super T> successConsumer,
Try.TryConsumer<? super java.lang.Throwable> failureConsumer) |
A functional if then else: if the Try is successful the successConsumer is used, otherwise
the
throwable consumer.
|
<U> Try<U> |
Try.map(Try.TryMapper<? super T,? extends U> mapper) |
If the Try is successful, another Try will be returned with the
result of the specified mapper,
otherwise the current Try is returned
|
<U> Try<U> |
Try.mapOrElse(Try.TryMapper<? super T,? extends U> ifSuccess,
Try.TryMapper<? super java.lang.Throwable,? extends U> orElse) |
A functional if then else: if the Try is successful the ifSuccess mapper is used,
otherwise the
throwable mapper.
|
static <T> Try<T> |
Try.of(Try.TryValueSupplier<? extends T> supplier) |
Creates a Try monad with the result of a computation
|
static <T> Try<T> |
Try.ofCallable(UnChecked.CheckedCallable<? extends T> function) |
|
static Try<java.lang.Void> |
Try.ofRunnable(UnChecked.CheckedRunnable function) |
|
Try<T> |
Try.orElseTry(Try.TryMapper<java.lang.Throwable,Try<? extends T>> excToAlternative) |
Gets the current Try or if it is a failure maps the generated exception into an
alternative Try using
the specified mapper
|
Try<T> |
Try.orElseTry(Try.TryValueSupplier<? extends T> supplier) |
Gets the current Try or if it is a failure, the result of the provided TrySupplier
|
Try<T> |
Try.orElseTry(Try.TryValueSupplier<? extends T> supplier,
UnChecked.CheckedConsumer<? super java.lang.Throwable> exceptionConsumer) |
Gets the current Try or if it is a failure, the result of the provided TrySupplier and the specified consumer
process the exception that has generated the failure
|
Try<T> |
Try.orElseTry(Try<? extends T> alternative) |
Gets the value contained in Try on success, otherwise returns the specified Try
|
<ExceptionT extends java.lang.Throwable> Try<T> |
Try.peek(java.lang.Class<? extends ExceptionT> throwableClass,
java.util.function.Consumer<? super T> ifSuccess,
java.util.function.Consumer<? super ExceptionT> ifError) |
Check the status of the current Try and apply accordingly one of the provided consumers.
|
Try<T> |
Try.peek(java.util.function.Consumer<? super T> ifSuccess,
java.util.function.Consumer<? super java.lang.Throwable> ifError) |
Check the status of the current Try and apply accordingly one of the provided consumers.
|
<ExceptionT extends java.lang.Throwable> Try<T> |
Try.peekFailure(java.lang.Class<ExceptionT> throwableClass,
java.util.function.Consumer<ExceptionT> ifError) |
Check if the status of the current Try is a failure of the specified class and in that
case apply
the specified consumer to its failure cause.
|
Try<T> |
Try.peekFailure(java.util.function.Consumer<? super java.lang.Throwable> ifError) |
Check if the current Try is a Failure and in that case apply the specified consumer to its
failure cause.
|
Try<T> |
Try.peekSuccess(java.util.function.Consumer<? super T> ifSuccess) |
Check the status of the current Try and if it is a success apply the specified consumer to
its value.
|
<X extends java.lang.Throwable> Try<T> |
Try.recover(java.lang.Class<X> exception,
Try.TryMapper<? super java.lang.Throwable,? extends T> alternativeMapper) |
Recover the status of a Try, if failed, mapping the generated exception to another org
.reacted.patterns.Try
Will be returned the original Try if it is successful, otherwise the try returned by the
mapper
Different recover calls can be chains for fine exception handling
|
<X extends java.lang.Throwable> Try<T> |
Try.recover(java.lang.Class<X> exception,
Try.TryValueSupplier<? extends T> successValGenerator) |
Recover the status of a Try, if failed.
|
<X extends java.lang.Throwable> Try<T> |
Try.recover(java.lang.Class<X> exception,
Try<? extends T> successValue) |
Recover the status of a Try, if failed.
|
<X extends java.lang.Throwable> Try<T> |
Try.recover(java.lang.Class<X> exception,
UnChecked.CheckedSupplier<Try<? extends T>> successProvider) |
Recover the status of a Try, if failed, a success Try is generated using the provided supplier
Will be returned the original Try if it is successful, otherwise the try returned by the
mapper
Different recover calls can be chains for fine exception handling
|
static <T,
A extends java.lang.AutoCloseable,
A1 extends java.lang.AutoCloseable> Try<T> |
Try.withChainedResources(Try.TryResourceSupplier<? extends A> resourceSupplier1,
Try.TryMapper<A,? extends A1> resourceMapper,
UnChecked.CheckedBiFunction<? super A,? super A1,? extends T> resourceToResult) |
|
static <T,
A extends java.lang.AutoCloseable> Try<T> |
Try.withResources(Try.TryResourceSupplier<? extends A> resourceSupplier,
Try.TryMapper<? super A,? extends T> resourceToResult) |
Applies a consumer on a resource.
|
static <T,
A extends java.lang.AutoCloseable,
A1 extends java.lang.AutoCloseable> Try<T> |
Try.withResources(Try.TryResourceSupplier<? extends A> resourceSupplier1,
Try.TryResourceSupplier<? extends A1> resourceSupplier2,
UnChecked.CheckedBiFunction<? super A,? super A1,? extends T> resourceToResult) |
Applies a consumer on two resources.
|