public final class Try<T extends java.lang.AutoCloseable>
extends java.lang.Object
RuntimeException
.Modifier and Type | Class and Description |
---|---|
static interface |
Try.BiConsumer<T,U,E extends java.lang.Exception> |
static interface |
Try.BiFunction<T,U,R,E extends java.lang.Exception> |
static interface |
Try.BiPredicate<T,U,E extends java.lang.Exception> |
static interface |
Try.Callable<R,E extends java.lang.Exception> |
static interface |
Try.Consumer<T,E extends java.lang.Exception> |
static interface |
Try.Function<T,R,E extends java.lang.Exception> |
static interface |
Try.Predicate<T,E extends java.lang.Exception> |
static interface |
Try.Runnable<E extends java.lang.Exception> |
static interface |
Try.Supplier<T,E extends java.lang.Exception> |
static interface |
Try.TriConsumer<A,B,C,E extends java.lang.Exception> |
static interface |
Try.TriFunction<A,B,C,R,E extends java.lang.Exception> |
static interface |
Try.TriPredicate<A,B,C,E extends java.lang.Exception> |
Modifier and Type | Method and Description |
---|---|
static <R> R |
call(java.util.concurrent.Callable<R> cmd) |
static <R> R |
call(java.util.concurrent.Callable<R> cmd,
Function<? super java.lang.Exception,R> actionOnError) |
static <R> R |
call(java.util.concurrent.Callable<R> cmd,
Predicate<? super java.lang.Exception> predicate,
R defaultValue) |
static <R> R |
call(java.util.concurrent.Callable<R> cmd,
Predicate<? super java.lang.Exception> predicate,
Supplier<R> supplier) |
static <R> R |
call(java.util.concurrent.Callable<R> cmd,
R defaultValue) |
static <R> R |
call(java.util.concurrent.Callable<R> cmd,
Supplier<R> supplier) |
<R> R |
call(Try.Function<? super T,R,? extends java.lang.Exception> cmd) |
<R> R |
call(Try.Function<? super T,R,? extends java.lang.Exception> cmd,
Function<? super java.lang.Exception,R> actionOnError) |
<R> R |
call(Try.Function<? super T,R,? extends java.lang.Exception> cmd,
Predicate<? super java.lang.Exception> predicate,
R defaultValue) |
<R> R |
call(Try.Function<? super T,R,? extends java.lang.Exception> cmd,
Predicate<? super java.lang.Exception> predicate,
Supplier<R> supplier) |
<R> R |
call(Try.Function<? super T,R,? extends java.lang.Exception> cmd,
R defaultValue) |
<R> R |
call(Try.Function<? super T,R,? extends java.lang.Exception> cmd,
Supplier<R> supplier) |
static <T extends java.lang.AutoCloseable> |
of(T t) |
static <T extends java.lang.AutoCloseable> |
of(Try.Supplier<T,? extends java.lang.Exception> supplier) |
static Try<java.io.Reader> |
reader(java.io.File file) |
void |
run(Try.Consumer<? super T,? extends java.lang.Exception> cmd) |
void |
run(Try.Consumer<? super T,? extends java.lang.Exception> cmd,
Consumer<? super java.lang.Exception> actionOnError) |
static void |
run(Try.Runnable<? extends java.lang.Exception> cmd) |
static void |
run(Try.Runnable<? extends java.lang.Exception> cmd,
Consumer<? super java.lang.Exception> actionOnError) |
static Try<Stream<java.lang.String>> |
stream(java.io.File file) |
T |
val() |
static Try<java.io.Writer> |
writer(java.io.File file) |
public static <T extends java.lang.AutoCloseable> Try<T> of(T t)
public static <T extends java.lang.AutoCloseable> Try<T> of(Try.Supplier<T,? extends java.lang.Exception> supplier)
public static Try<java.io.Reader> reader(java.io.File file)
public static Try<java.io.Writer> writer(java.io.File file)
public static void run(Try.Runnable<? extends java.lang.Exception> cmd)
cmd
- java.lang.RuntimeException
- if some error happenspublic static void run(Try.Runnable<? extends java.lang.Exception> cmd, Consumer<? super java.lang.Exception> actionOnError)
public static <R> R call(java.util.concurrent.Callable<R> cmd)
cmd
- java.lang.RuntimeException
- if some error happenspublic static <R> R call(java.util.concurrent.Callable<R> cmd, Function<? super java.lang.Exception,R> actionOnError)
public static <R> R call(java.util.concurrent.Callable<R> cmd, Supplier<R> supplier)
public static <R> R call(java.util.concurrent.Callable<R> cmd, R defaultValue)
public static <R> R call(java.util.concurrent.Callable<R> cmd, Predicate<? super java.lang.Exception> predicate, Supplier<R> supplier)
cmd
- predicate
- supplier
- Supplier.get()
if some error happens and predicate
return true.java.lang.RuntimeException
- if some error happens and predicate
return false.public static <R> R call(java.util.concurrent.Callable<R> cmd, Predicate<? super java.lang.Exception> predicate, R defaultValue)
cmd
- predicate
- defaultValue
- defaultValue()
if some error happens and predicate
return true.java.lang.RuntimeException
- if some error happens and predicate
return false.public T val()
public void run(Try.Consumer<? super T,? extends java.lang.Exception> cmd)
public void run(Try.Consumer<? super T,? extends java.lang.Exception> cmd, Consumer<? super java.lang.Exception> actionOnError)
public <R> R call(Try.Function<? super T,R,? extends java.lang.Exception> cmd)
public <R> R call(Try.Function<? super T,R,? extends java.lang.Exception> cmd, Function<? super java.lang.Exception,R> actionOnError)
public <R> R call(Try.Function<? super T,R,? extends java.lang.Exception> cmd, Supplier<R> supplier)
public <R> R call(Try.Function<? super T,R,? extends java.lang.Exception> cmd, R defaultValue)
public <R> R call(Try.Function<? super T,R,? extends java.lang.Exception> cmd, Predicate<? super java.lang.Exception> predicate, Supplier<R> supplier)
public <R> R call(Try.Function<? super T,R,? extends java.lang.Exception> cmd, Predicate<? super java.lang.Exception> predicate, R defaultValue)