public final class Try<T extends AutoCloseable> extends Object
| Modifier and Type | Method and Description |
|---|---|
static <R> R |
call(Callable<R> cmd) |
static <R> R |
call(Callable<R> cmd,
Function<? super Exception,R> actionOnError) |
static <R> R |
call(Callable<R> cmd,
Predicate<? super Exception> predicate,
R defaultValue) |
static <R> R |
call(Callable<R> cmd,
Predicate<? super Exception> predicate,
Supplier<R> supplier) |
static <R> R |
call(Callable<R> cmd,
R defaultValue) |
static <R> R |
call(Callable<R> cmd,
Supplier<R> supplier) |
<R> R |
call(Throwables.Function<? super T,R,? extends Exception> cmd) |
<R> R |
call(Throwables.Function<? super T,R,? extends Exception> cmd,
Function<? super Exception,R> actionOnError) |
<R> R |
call(Throwables.Function<? super T,R,? extends Exception> cmd,
Predicate<? super Exception> predicate,
R defaultValue) |
<R> R |
call(Throwables.Function<? super T,R,? extends Exception> cmd,
Predicate<? super Exception> predicate,
Supplier<R> supplier) |
<R> R |
call(Throwables.Function<? super T,R,? extends Exception> cmd,
R defaultValue) |
<R> R |
call(Throwables.Function<? super T,R,? extends Exception> cmd,
Supplier<R> supplier) |
void |
run(Throwables.Consumer<? super T,? extends Exception> cmd) |
void |
run(Throwables.Consumer<? super T,? extends Exception> cmd,
Consumer<? super Exception> actionOnError) |
static void |
run(Throwables.Runnable<? extends Exception> cmd) |
static void |
run(Throwables.Runnable<? extends Exception> cmd,
Consumer<? super Exception> actionOnError) |
static <T extends AutoCloseable> |
with(Runnable finalAction) |
static <T extends AutoCloseable> |
with(T targetResource) |
static <T extends AutoCloseable> |
with(Throwables.Supplier<T,? extends Exception> targetResourceSupplier) |
static <T extends AutoCloseable> |
with(Throwables.Supplier<T,? extends Exception> targetResourceSupplier,
Runnable finalAction) |
static <T extends AutoCloseable> |
with(T targetResource,
Runnable finalAction) |
public static <T extends AutoCloseable> Try<T> with(T targetResource)
public static <T extends AutoCloseable> Try<T> with(T targetResource, Runnable finalAction)
public static <T extends AutoCloseable> Try<T> with(Throwables.Supplier<T,? extends Exception> targetResourceSupplier)
public static <T extends AutoCloseable> Try<T> with(Throwables.Supplier<T,? extends Exception> targetResourceSupplier, Runnable finalAction)
public static <T extends AutoCloseable> Try<T> with(Runnable finalAction)
T - targetResource - public static void run(Throwables.Runnable<? extends Exception> cmd)
cmd - RuntimeException - if some error happenspublic static void run(Throwables.Runnable<? extends Exception> cmd, Consumer<? super Exception> actionOnError)
cmd - actionOnError - public static <R> R call(Callable<R> cmd)
R - cmd - RuntimeException - if some error happenspublic static <R> R call(Callable<R> cmd, Function<? super Exception,R> actionOnError)
R - cmd - actionOnError - public static <R> R call(Callable<R> cmd, Supplier<R> supplier)
R - cmd - supplier - public static <R> R call(Callable<R> cmd, R defaultValue)
R - cmd - defaultValue - public static <R> R call(Callable<R> cmd, Predicate<? super Exception> predicate, Supplier<R> supplier)
R - cmd - predicate - supplier - RuntimeException - if some error happens and predicate return false.public static <R> R call(Callable<R> cmd, Predicate<? super Exception> predicate, R defaultValue)
R - cmd - predicate - defaultValue - RuntimeException - if some error happens and predicate return false.public void run(Throwables.Consumer<? super T,? extends Exception> cmd)
cmd - public void run(Throwables.Consumer<? super T,? extends Exception> cmd, Consumer<? super Exception> actionOnError)
cmd - actionOnError - public <R> R call(Throwables.Function<? super T,R,? extends Exception> cmd)
R - cmd - public <R> R call(Throwables.Function<? super T,R,? extends Exception> cmd, Function<? super Exception,R> actionOnError)
R - cmd - actionOnError - public <R> R call(Throwables.Function<? super T,R,? extends Exception> cmd, Supplier<R> supplier)
R - cmd - supplier - public <R> R call(Throwables.Function<? super T,R,? extends Exception> cmd, R defaultValue)
R - cmd - defaultValue - public <R> R call(Throwables.Function<? super T,R,? extends Exception> cmd, Predicate<? super Exception> predicate, Supplier<R> supplier)
R - cmd - predicate - supplier - public <R> R call(Throwables.Function<? super T,R,? extends Exception> cmd, Predicate<? super Exception> predicate, R defaultValue)
R - cmd - predicate - defaultValue - Copyright © 2021. All rights reserved.