-
Method Summary
Modifier and TypeMethodDescriptionstatic voidchecked(UnsafeRunnable runnable) Gracefully runs anUnsafeRunnable.static <T> Tchecked(UnsafeSupplier<T> supplier) Gracefully gets from anUnsafeSupplier.static <T extends Exception>
voidchecked(Class<T> expectedExceptionClass, UnsafeRunnable runnable) Gracefully runs anUnsafeRunnable.static <T,T1 extends Exception>
Tchecked(Class<T1> expectedExceptionClass, UnsafeSupplier<T> supplier) Gracefully gets from anUnsafeSupplier.checked(Class<T1> expectedExceptionClass1, Class<T2> expectedExceptionClass2, UnsafeRunnable runnable) Gracefully runs anUnsafeRunnable.checked(Class<T1> expectedExceptionClass1, Class<T2> expectedExceptionClass2, UnsafeSupplier<T> supplier) Gracefully gets from anUnsafeSupplier.checked(Class<T1> expectedExceptionClass1, Class<T2> expectedExceptionClass2, Class<T3> expectedExceptionClass3, UnsafeRunnable runnable) Gracefully runs anUnsafeRunnable.checked(Class<T1> expectedExceptionClass1, Class<T2> expectedExceptionClass2, Class<T3> expectedExceptionClass3, UnsafeSupplier<T> supplier) Gracefully gets from anUnsafeSupplier.checked(Class<T1> expectedExceptionClass1, Class<T2> expectedExceptionClass2, Class<T3> expectedExceptionClass3, T argument, UnsafeConsumer<T> consumer) Gracefully supplies a value to anUnsafeConsumer.checked(Class<T1> expectedExceptionClass1, Class<T2> expectedExceptionClass2, Class<T3> expectedExceptionClass3, T argument, UnsafeFunction<T, R> function) Gracefully applies anUnsafeFunction.checked(Class<T1> expectedExceptionClass1, Class<T2> expectedExceptionClass2, Class<T3> expectedExceptionClass3, T firstArgument, U secondArgument, UnsafeBiConsumer<T, U> consumer) Gracefully supplies a value to anUnsafeBiConsumer.checked(Class<T1> expectedExceptionClass1, Class<T2> expectedExceptionClass2, Class<T3> expectedExceptionClass3, T firstArgument, U secondArgument, UnsafeBiFunction<T, U, R> function) Gracefully applies anUnsafeBiFunction.checked(Class<T1> expectedExceptionClass1, Class<T2> expectedExceptionClass2, T argument, UnsafeConsumer<T> consumer) Gracefully supplies a value to anUnsafeConsumer.checked(Class<T1> expectedExceptionClass1, Class<T2> expectedExceptionClass2, T argument, UnsafeFunction<T, R> function) Gracefully applies anUnsafeFunction.checked(Class<T1> expectedExceptionClass1, Class<T2> expectedExceptionClass2, T firstArgument, U secondArgument, UnsafeBiConsumer<T, U> consumer) Gracefully supplies a value to anUnsafeBiConsumer.checked(Class<T1> expectedExceptionClass1, Class<T2> expectedExceptionClass2, T firstArgument, U secondArgument, UnsafeBiFunction<T, U, R> function) Gracefully applies anUnsafeBiFunction.static <T,T1 extends Exception>
voidchecked(Class<T1> expectedExceptionClass, T argument, UnsafeConsumer<T> consumer) Gracefully supplies a value to anUnsafeConsumer.static <T,R, T1 extends Exception>
Rchecked(Class<T1> expectedExceptionClass, T argument, UnsafeFunction<T, R> function) Gracefully applies anUnsafeFunction.static <T,U, T1 extends Exception>
voidchecked(Class<T1> expectedExceptionClass, T firstArgument, U secondArgument, UnsafeBiConsumer<T, U> consumer) Gracefully supplies a value to anUnsafeBiConsumer.static <T,U, R, T1 extends Exception>
Rchecked(Class<T1> expectedExceptionClass, T firstArgument, U secondArgument, UnsafeBiFunction<T, U, R> function) Gracefully applies anUnsafeBiFunction.static ExceptionExpects aThrowableto be achecked exception.static <T extends Exception>
TExpects aThrowableto be a specificchecked exception.Expects aThrowableto be a specificchecked exception.checked(Throwable throwable, Class<T1> expectedExceptionClass1, Class<T2> expectedExceptionClass2, Class<T3> expectedExceptionClass3) Expects aThrowableto be a specificchecked exception.static <T> voidchecked(T argument, UnsafeConsumer<T> consumer) Gracefully supplies a value to anUnsafeConsumer.static <T,R> R checked(T argument, UnsafeFunction<T, R> function) Gracefully applies anUnsafeFunction.static <T,U> void checked(T firstArgument, U secondArgument, UnsafeBiConsumer<T, U> consumer) Gracefully supplies a value to anUnsafeBiConsumer.static <T,U, R> R checked(T firstArgument, U secondArgument, UnsafeBiFunction<T, U, R> function) Gracefully applies anUnsafeBiFunction.static <R> RcheckedInvocation(UnsafeSupplier<R> supplier) Gracefully invokes amethod or constructor.static <R,T extends Exception>
RcheckedInvocation(Class<T> expectedExceptionClass, UnsafeSupplier<R> supplier) Gracefully invokes amethod or constructor.checkedInvocation(Class<T1> expectedExceptionClass1, Class<T2> expectedExceptionClass2, UnsafeSupplier<R> supplier) Gracefully invokes amethod or constructor.checkedInvocation(Class<T1> expectedExceptionClass1, Class<T2> expectedExceptionClass2, Class<T3> expectedExceptionClass3, UnsafeSupplier<R> supplier) Gracefully invokes amethod or constructor.static <T extends AutoCloseable,R>
Rinitialize(T resource, UnsafeFunction<T, R> initializer) Gracefully initializes a component that depends on anAutoCloseableresource,closingthe resource and suppressing any close errors before rethrowing a checked exception if the component fails to initialize.static voidsuppress(UnsafeRunnable... tasks) Runs a sequence of tasks with error suppression.static voidsuppress(Iterable<UnsafeRunnable> tasks) Runs a sequence of tasks with error suppression.static Throwablesuppress(Throwable throwable, UnsafeRunnable runnable) Runs anUnsafeRunnableand adds any exception thrown as suppressed by an another exception.static Stringstatic voidunchecked(UnsafeRunnable runnable) Gracefully runs anUnsafeRunnable.static voidunchecked(UnsafeRunnable runnable, String message) Gracefully runs anUnsafeRunnable.static <T> Tunchecked(UnsafeSupplier<T> supplier) Gracefully gets from anUnsafeSupplier.static <T> Tunchecked(UnsafeSupplier<T> supplier, String message) Gracefully gets from anUnsafeSupplier.static RuntimeExceptionExpects aThrowableto be an (unchecked)RuntimeException.static RuntimeExceptionExpects aThrowableto be an (unchecked)RuntimeException.static <T> voidunchecked(T argument, UnsafeConsumer<T> consumer) Gracefully supplies a value to anUnsafeConsumer.static <T,R> R unchecked(T argument, UnsafeFunction<T, R> function) Gracefully applies anUnsafeFunction.static <T,U> void unchecked(T firstArgument, U secondArgument, UnsafeBiConsumer<T, U> consumer) Gracefully supplies a value to anUnsafeBiConsumer.static <T,U, R> R unchecked(T firstArgument, U secondArgument, UnsafeBiFunction<T, U, R> function) Gracefully applies anUnsafeBiFunction.static <R> RuncheckedInvocation(UnsafeSupplier<R> supplier) Gracefully invokes a supplier assumed to wrapinvocation.
-
Method Details
-
unchecked
Expects aThrowableto be an (unchecked)RuntimeException.This method may be used as an exception handler in situations where
Throwableor one or morechecked exceptionsare thrown from a downstream invocation, but achecked exceptionmust not be thrown from the interface being implemented and no special handling is specified.try { // something unsafe } catch (Throwable e) { throw IuException.unchecked(e); }- Parameters:
throwable- AnyThrowable- Returns:
throwableifRuntimeException- Throws:
IllegalStateException- ifthrowableis achecked exceptionorcustom throwableError- ifthrowableis anError
-
unchecked
public static RuntimeException unchecked(Throwable throwable, String message) throws IllegalStateException, Error Expects aThrowableto be an (unchecked)RuntimeException.This method may be used as an exception handler in situations where
Throwableor one or morechecked exceptionsare thrown from a downstream invocation, but achecked exceptionmust not be thrown from the interface being implemented and no special handling is specified.try { // something unsafe } catch (Throwable e) { throw IuException.unchecked(e); }- Parameters:
throwable- AnyThrowablemessage- Message to use withIllegalStateExceptionif throwable is not aRuntimeExceptionorError- Returns:
throwableifRuntimeException- Throws:
IllegalStateException- ifthrowableis achecked exceptionorcustom throwableError- ifthrowableis anError
-
checked
Expects aThrowableto be achecked exception.This method may be used as an exception handler in situations where
Throwableis thrown from a downstream invocation, but onlyexceptionmay be thrown from the interface being implemented and special handling is not specified forcustom throwables.try { // something unsafe } catch (Throwable e) { throw IuException.checked(e); }- Parameters:
throwable- AnyThrowable- Returns:
throwableifException- Throws:
IllegalStateException- ifthrowableis acustom throwableError- ifthrowableis anError
-
checked
public static <T extends Exception> T checked(Throwable throwable, Class<T> expectedExceptionClass) throws RuntimeException, Error, IllegalStateException Expects aThrowableto be a specificchecked exception.This method may be used as an exception handler in situations where
Throwable,Exception, or specificchecked exceptionsare thrown from a downstream invocation, but at least one of these must not be thrown from the interface being implemented and special handling is not specified for the unexpectedthrowable types.try { // something unsafe } catch (Throwable e) { throw IuException.checked(e, ACheckedException.class); }- Type Parameters:
T- Expected exception type- Parameters:
throwable- AnyThrowableexpectedExceptionClass- Expected exception class- Returns:
throwableifinstanceof T- Throws:
RuntimeException- ifthrowableis aRuntimeExceptionError- ifthrowableis anErrorIllegalStateException- ifthrowableis custom or achecked exceptionother thanT
-
checked
public static <T1 extends Exception,T2 extends Exception> T1 checked(Throwable throwable, Class<T1> expectedExceptionClass1, Class<T2> expectedExceptionClass2) throws T2, RuntimeException, Error, IllegalStateException Expects aThrowableto be a specificchecked exception.This method may be used as an exception handler in situations where
Throwable,Exception, or specificchecked exceptionsare thrown from a downstream invocation, but at least one of these must not be thrown from the interface being implemented and special handling is not specified for the unexpectedthrowable types.try { // something unsafe } catch (Throwable e) { throw IuException.checked(e, ACheckedException.class, AnotherCheckedException.class); }- Type Parameters:
T1- Expected exception typeT2- Additional exception type that may be thrown- Parameters:
throwable- AnyThrowableexpectedExceptionClass1- Expected exception classexpectedExceptionClass2- Additional exception class that may be thrown- Returns:
throwableifinstanceof T1- Throws:
T2- ifthrowableisT2RuntimeException- ifthrowableis aRuntimeExceptionError- ifthrowableis anErrorIllegalStateException- ifthrowableis custom or achecked exceptionother thanTbe thrown
-
checked
public static <T1 extends Exception,T2 extends Exception, T1 checkedT3 extends Exception> (Throwable throwable, Class<T1> expectedExceptionClass1, Class<T2> expectedExceptionClass2, Class<T3> expectedExceptionClass3) throws T2, T3, RuntimeException, Error, IllegalStateException Expects aThrowableto be a specificchecked exception.This method may be used as an exception handler in situations where
Throwable,Exception, or specificchecked exceptionsare thrown from a downstream invocation, but at least one of these must not be thrown from the interface being implemented and special handling is not specified for the unexpectedthrowable types.try { // something unsafe } catch (Throwable e) { throw IuException.checked(e, ACheckedException.class, AnotherCheckedException.class, YetAnotherCheckedException.class); }- Type Parameters:
T1- Expected exception typeT2- Additional exception type that may be thrownT3- Additional exception type that may be thrown- Parameters:
throwable- AnyThrowableexpectedExceptionClass1- Expected exception classexpectedExceptionClass2- Additional exception class that may be thrownexpectedExceptionClass3- Additional exception class that may be thrown- Returns:
throwableifinstanceof T1- Throws:
T2- ifthrowableisT2T3- ifthrowableisT3RuntimeException- ifthrowableis aRuntimeExceptionError- ifthrowableis anErrorIllegalStateException- ifthrowableis custom or achecked exceptionother thanTbe thrown
-
uncheckedInvocation
Gracefully invokes a supplier assumed to wrapinvocation.Handles
InvocationTargetExceptionby unwrapping the cause and re-throwing.Handles other exceptions via
unchecked(Throwable).- Type Parameters:
R- result type- Parameters:
supplier-UnsafeSupplierassumed to wrapinvocation.- Returns:
- result
-
checkedInvocation
Gracefully invokes amethod or constructor.Handles
InvocationTargetExceptionby unwrapping the cause and re-throwing.Handles other exceptions via
checked(Throwable).- Type Parameters:
R- result type- Parameters:
supplier-UnsafeSupplierassumed to wrapinvocation.- Returns:
- result
- Throws:
Exception- If invocation fails
-
checkedInvocation
public static <R,T extends Exception> R checkedInvocation(Class<T> expectedExceptionClass, UnsafeSupplier<R> supplier) throws T Gracefully invokes amethod or constructor.Handles
InvocationTargetExceptionby unwrapping the cause and re-throwing.Handles other exceptions via
checked(Throwable, Class).- Type Parameters:
R- result typeT- Expected exception type- Parameters:
expectedExceptionClass- Expected exception classsupplier-UnsafeSupplierassumed to wrapinvocation.- Returns:
- result
- Throws:
T- If invocation fails
-
checkedInvocation
public static <R,T1 extends Exception, R checkedInvocationT2 extends Exception> (Class<T1> expectedExceptionClass1, Class<T2> expectedExceptionClass2, UnsafeSupplier<R> supplier) throws T1, T2 Gracefully invokes amethod or constructor.Handles
InvocationTargetExceptionby unwrapping the cause and re-throwing.Handles other exceptions via
checked(Throwable, Class, Class).- Type Parameters:
R- result typeT1- Expected exception typeT2- Expected exception type- Parameters:
expectedExceptionClass1- Expected exception classexpectedExceptionClass2- Expected exception classsupplier-UnsafeSupplierassumed to wrapinvocation.- Returns:
- result
- Throws:
T1- If invocation failsT2- If invocation fails
-
checkedInvocation
public static <R,T1 extends Exception, R checkedInvocationT2 extends Exception, T3 extends Exception> (Class<T1> expectedExceptionClass1, Class<T2> expectedExceptionClass2, Class<T3> expectedExceptionClass3, UnsafeSupplier<R> supplier) throws T1, T2, T3 Gracefully invokes amethod or constructor.Handles
InvocationTargetExceptionby unwrapping the cause and re-throwing.Handles other exceptions via
checked(Throwable, Class, Class, Class).- Type Parameters:
R- result typeT1- Expected exception typeT2- Expected exception typeT3- Expected exception type- Parameters:
expectedExceptionClass1- Expected exception classexpectedExceptionClass2- Expected exception classexpectedExceptionClass3- Expected exception classsupplier-UnsafeSupplierassumed to wrapinvocation.- Returns:
- result
- Throws:
T1- If invocation failsT2- If invocation failsT3- If invocation fails
-
unchecked
Gracefully runs anUnsafeRunnable.Handles exceptions via
unchecked(Throwable).- Parameters:
runnable- AnyUnsafeRunnable
-
unchecked
Gracefully runs anUnsafeRunnable.Handles exceptions via
unchecked(Throwable).- Parameters:
runnable- AnyUnsafeRunnablemessage- message for use withunchecked(Throwable, String)
-
checked
Gracefully runs anUnsafeRunnable.Handles exceptions via
checked(Throwable).- Parameters:
runnable- AnyUnsafeRunnable- Throws:
Exception- If thrown byUnsafeRunnable.run()
-
checked
public static <T extends Exception> void checked(Class<T> expectedExceptionClass, UnsafeRunnable runnable) throws T Gracefully runs anUnsafeRunnable.Handles exceptions via
checked(Throwable, Class).- Type Parameters:
T- Expected exception type- Parameters:
expectedExceptionClass- Expected exception classrunnable- AnyUnsafeRunnable- Throws:
T- If thrown byUnsafeRunnable.run()
-
checked
public static <T1 extends Exception,T2 extends Exception> void checked(Class<T1> expectedExceptionClass1, Class<T2> expectedExceptionClass2, UnsafeRunnable runnable) throws T1, T2 Gracefully runs anUnsafeRunnable.Handles exceptions via
checked(Throwable, Class, Class).- Type Parameters:
T1- Expected exception typeT2- Expected exception type- Parameters:
expectedExceptionClass1- Expected exception classexpectedExceptionClass2- Expected exception classrunnable- AnyUnsafeRunnable- Throws:
T1- If thrown byUnsafeRunnable.run()T2- If thrown byUnsafeRunnable.run()
-
checked
public static <T1 extends Exception,T2 extends Exception, void checkedT3 extends Exception> (Class<T1> expectedExceptionClass1, Class<T2> expectedExceptionClass2, Class<T3> expectedExceptionClass3, UnsafeRunnable runnable) throws T1, T2, T3 Gracefully runs anUnsafeRunnable.Handles exceptions via
checked(Throwable, Class, Class, Class).- Type Parameters:
T1- Expected exception typeT2- Expected exception typeT3- Expected exception type- Parameters:
expectedExceptionClass1- Expected exception classexpectedExceptionClass2- Expected exception classexpectedExceptionClass3- Expected exception classrunnable- AnyUnsafeRunnable- Throws:
T1- If thrown byUnsafeRunnable.run()T2- If thrown byUnsafeRunnable.run()T3- If thrown byUnsafeRunnable.run()
-
unchecked
Gracefully gets from anUnsafeSupplier.Handles exceptions via
unchecked(Throwable).- Type Parameters:
T- result type- Parameters:
supplier- AnyUnsafeSupplier- Returns:
- result
-
unchecked
Gracefully gets from anUnsafeSupplier.Handles exceptions via
unchecked(Throwable).- Type Parameters:
T- result type- Parameters:
supplier- AnyUnsafeSuppliermessage- Message to use withunchecked(Throwable, String)- Returns:
- result
-
checked
Gracefully gets from anUnsafeSupplier.Handles exceptions via
checked(Throwable).- Type Parameters:
T- result type- Parameters:
supplier- AnyUnsafeSupplier- Returns:
- result
- Throws:
Exception- If thrown byUnsafeSupplier.get()
-
checked
public static <T,T1 extends Exception> T checked(Class<T1> expectedExceptionClass, UnsafeSupplier<T> supplier) throws T1 Gracefully gets from anUnsafeSupplier.Handles exceptions via
checked(Throwable, Class).- Type Parameters:
T- result typeT1- Expected exception type- Parameters:
expectedExceptionClass- Expected exception classsupplier- AnyUnsafeSupplier- Returns:
- result
- Throws:
T1- If thrown byUnsafeSupplier.get()
-
checked
public static <T,T1 extends Exception, T checkedT2 extends Exception> (Class<T1> expectedExceptionClass1, Class<T2> expectedExceptionClass2, UnsafeSupplier<T> supplier) throws T1, T2 Gracefully gets from anUnsafeSupplier.Handles exceptions via
checked(Throwable, Class, Class).- Type Parameters:
T- result typeT1- Expected exception typeT2- Expected exception type- Parameters:
expectedExceptionClass1- Expected exception classexpectedExceptionClass2- Expected exception classsupplier- AnyUnsafeSupplier- Returns:
- result
- Throws:
T1- If thrown byUnsafeSupplier.get()T2- If thrown byUnsafeSupplier.get()
-
checked
public static <T,T1 extends Exception, T checkedT2 extends Exception, T3 extends Exception> (Class<T1> expectedExceptionClass1, Class<T2> expectedExceptionClass2, Class<T3> expectedExceptionClass3, UnsafeSupplier<T> supplier) throws T1, T2, T3 Gracefully gets from anUnsafeSupplier.Handles exceptions via
checked(Throwable, Class, Class, Class).- Type Parameters:
T- result typeT1- Expected exception typeT2- Expected exception typeT3- Expected exception type- Parameters:
expectedExceptionClass1- Expected exception classexpectedExceptionClass2- Expected exception classexpectedExceptionClass3- Expected exception classsupplier- AnyUnsafeSupplier- Returns:
- result
- Throws:
T1- If thrown byUnsafeSupplier.get()T2- If thrown byUnsafeSupplier.get()T3- If thrown byUnsafeSupplier.get()
-
unchecked
Gracefully supplies a value to anUnsafeConsumer.Handles exceptions via
unchecked(Throwable).- Type Parameters:
T- argument type- Parameters:
argument- Argument forUnsafeConsumer.accept(Object)consumer- AnyUnsafeConsumer
-
checked
Gracefully supplies a value to anUnsafeConsumer.Handles exceptions via
checked(Throwable).- Type Parameters:
T- argument type- Parameters:
argument- Argument forUnsafeConsumer.accept(Object)consumer- AnyUnsafeConsumer- Throws:
Exception- If thrown byUnsafeConsumer.accept(Object)
-
checked
public static <T,T1 extends Exception> void checked(Class<T1> expectedExceptionClass, T argument, UnsafeConsumer<T> consumer) throws T1 Gracefully supplies a value to anUnsafeConsumer.Handles exceptions via
checked(Throwable, Class).- Type Parameters:
T- argument typeT1- Expected exception type- Parameters:
expectedExceptionClass- Expected exception classargument- Argument forUnsafeConsumer.accept(Object)consumer- AnyUnsafeConsumer- Throws:
T1- If thrown byUnsafeConsumer.accept(Object)
-
checked
public static <T,T1 extends Exception, void checkedT2 extends Exception> (Class<T1> expectedExceptionClass1, Class<T2> expectedExceptionClass2, T argument, UnsafeConsumer<T> consumer) throws T1, T2 Gracefully supplies a value to anUnsafeConsumer.Handles exceptions via
checked(Throwable, Class, Class).- Type Parameters:
T- argument typeT1- Expected exception typeT2- Expected exception type- Parameters:
expectedExceptionClass1- Expected exception classexpectedExceptionClass2- Expected exception classargument- Argument forUnsafeConsumer.accept(Object)consumer- AnyUnsafeConsumer- Throws:
T1- If thrown byUnsafeConsumer.accept(Object)T2- If thrown byUnsafeConsumer.accept(Object)
-
checked
public static <T,T1 extends Exception, void checkedT2 extends Exception, T3 extends Exception> (Class<T1> expectedExceptionClass1, Class<T2> expectedExceptionClass2, Class<T3> expectedExceptionClass3, T argument, UnsafeConsumer<T> consumer) throws T1, T2, T3 Gracefully supplies a value to anUnsafeConsumer.Handles exceptions via
checked(Throwable, Class, Class, Class).- Type Parameters:
T- argument typeT1- Expected exception typeT2- Expected exception typeT3- Expected exception type- Parameters:
expectedExceptionClass1- Expected exception classexpectedExceptionClass2- Expected exception classexpectedExceptionClass3- Expected exception classargument- Argument forUnsafeConsumer.accept(Object)consumer- AnyUnsafeConsumer- Throws:
T1- If thrown byUnsafeConsumer.accept(Object)T2- If thrown byUnsafeConsumer.accept(Object)T3- If thrown byUnsafeConsumer.accept(Object)
-
unchecked
Gracefully applies anUnsafeFunction.Handles exceptions via
unchecked(Throwable).- Type Parameters:
T- argument typeR- result type- Parameters:
argument- Argument toUnsafeFunction.apply(Object)function- AnyUnsafeFunction- Returns:
- result
-
checked
Gracefully applies anUnsafeFunction.Handles exceptions via
checked(Throwable).- Type Parameters:
T- argument typeR- result type- Parameters:
argument- Argument toUnsafeFunction.apply(Object)function- AnyUnsafeFunction- Returns:
- result
- Throws:
Exception- If thrown byUnsafeFunction.apply(Object)
-
checked
public static <T,R, R checkedT1 extends Exception> (Class<T1> expectedExceptionClass, T argument, UnsafeFunction<T, R> function) throws T1Gracefully applies anUnsafeFunction.Handles exceptions via
checked(Throwable, Class).- Type Parameters:
T- argument typeR- result typeT1- Expected exception type- Parameters:
expectedExceptionClass- Expected exception classargument- Argument toUnsafeFunction.apply(Object)function- AnyUnsafeFunction- Returns:
- result
- Throws:
T1- If thrown byUnsafeFunction.apply(Object)
-
checked
public static <T,R, R checkedT1 extends Exception, T2 extends Exception> (Class<T1> expectedExceptionClass1, Class<T2> expectedExceptionClass2, T argument, UnsafeFunction<T, R> function) throws T1, T2Gracefully applies anUnsafeFunction.Handles exceptions via
checked(Throwable, Class, Class).- Type Parameters:
T- argument typeR- result typeT1- Expected exception typeT2- Expected exception type- Parameters:
expectedExceptionClass1- Expected exception classexpectedExceptionClass2- Expected exception classargument- Argument toUnsafeFunction.apply(Object)function- AnyUnsafeFunction- Returns:
- result
- Throws:
T1- If thrown byUnsafeFunction.apply(Object)T2- If thrown byUnsafeFunction.apply(Object)
-
checked
public static <T,R, R checkedT1 extends Exception, T2 extends Exception, T3 extends Exception> (Class<T1> expectedExceptionClass1, Class<T2> expectedExceptionClass2, Class<T3> expectedExceptionClass3, T argument, UnsafeFunction<T, R> function) throws T1, T2, T3Gracefully applies anUnsafeFunction.Handles exceptions via
checked(Throwable, Class, Class, Class).- Type Parameters:
T- argument typeR- result typeT1- Expected exception typeT2- Expected exception typeT3- Expected exception type- Parameters:
expectedExceptionClass1- Expected exception classexpectedExceptionClass2- Expected exception classexpectedExceptionClass3- Expected exception classargument- Argument toUnsafeFunction.apply(Object)function- AnyUnsafeFunction- Returns:
- result
- Throws:
T1- If thrown byUnsafeFunction.apply(Object)T2- If thrown byUnsafeFunction.apply(Object)T3- If thrown byUnsafeFunction.apply(Object)
-
unchecked
public static <T,U> void unchecked(T firstArgument, U secondArgument, UnsafeBiConsumer<T, U> consumer) Gracefully supplies a value to anUnsafeBiConsumer.Handles exceptions via
unchecked(Throwable).- Type Parameters:
T- first argument typeU- second argument type- Parameters:
firstArgument- First argument forUnsafeBiConsumer.accept(Object,Object)secondArgument- Second argument forUnsafeBiConsumer.accept(Object,Object)consumer- AnyUnsafeBiConsumer
-
checked
public static <T,U> void checked(T firstArgument, U secondArgument, UnsafeBiConsumer<T, U> consumer) throws ExceptionGracefully supplies a value to anUnsafeBiConsumer.Handles exceptions via
checked(Throwable).- Type Parameters:
T- first argument typeU- second argument type- Parameters:
firstArgument- Argument forUnsafeBiConsumer.accept(Object,Object)secondArgument- Second argument forUnsafeBiConsumer.accept(Object,Object)consumer- AnyUnsafeBiConsumer- Throws:
Exception- If thrown byUnsafeBiConsumer.accept(Object,Object)
-
checked
public static <T,U, void checkedT1 extends Exception> (Class<T1> expectedExceptionClass, T firstArgument, U secondArgument, UnsafeBiConsumer<T, U> consumer) throws T1Gracefully supplies a value to anUnsafeBiConsumer.Handles exceptions via
checked(Throwable, Class).- Type Parameters:
T- first argument typeU- second argument typeT1- Expected exception type- Parameters:
expectedExceptionClass- Expected exception classfirstArgument- Argument forUnsafeBiConsumer.accept(Object,Object)secondArgument- Second argument forUnsafeBiConsumer.accept(Object,Object)consumer- AnyUnsafeBiConsumer- Throws:
T1- If thrown byUnsafeBiConsumer.accept(Object,Object)
-
checked
public static <T,U, void checkedT1 extends Exception, T2 extends Exception> (Class<T1> expectedExceptionClass1, Class<T2> expectedExceptionClass2, T firstArgument, U secondArgument, UnsafeBiConsumer<T, U> consumer) throws T1, T2Gracefully supplies a value to anUnsafeBiConsumer.Handles exceptions via
checked(Throwable, Class, Class).- Type Parameters:
T- first argument typeU- second argument typeT1- Expected exception typeT2- Expected exception type- Parameters:
expectedExceptionClass1- Expected exception classexpectedExceptionClass2- Expected exception classfirstArgument- Argument forUnsafeBiConsumer.accept(Object,Object)secondArgument- Second argument forUnsafeBiConsumer.accept(Object,Object)consumer- AnyUnsafeBiConsumer- Throws:
T1- If thrown byUnsafeBiConsumer.accept(Object,Object)T2- If thrown byUnsafeBiConsumer.accept(Object,Object)
-
checked
public static <T,U, void checkedT1 extends Exception, T2 extends Exception, T3 extends Exception> (Class<T1> expectedExceptionClass1, Class<T2> expectedExceptionClass2, Class<T3> expectedExceptionClass3, T firstArgument, U secondArgument, UnsafeBiConsumer<T, U> consumer) throws T1, T2, T3Gracefully supplies a value to anUnsafeBiConsumer.Handles exceptions via
checked(Throwable, Class, Class, Class).- Type Parameters:
T- first argument typeU- second argument typeT1- Expected exception typeT2- Expected exception typeT3- Expected exception type- Parameters:
expectedExceptionClass1- Expected exception classexpectedExceptionClass2- Expected exception classexpectedExceptionClass3- Expected exception classfirstArgument- Argument forUnsafeBiConsumer.accept(Object,Object)secondArgument- Second argument forUnsafeBiConsumer.accept(Object,Object)consumer- AnyUnsafeBiConsumer- Throws:
T1- If thrown byUnsafeBiConsumer.accept(Object,Object)T2- If thrown byUnsafeBiConsumer.accept(Object,Object)T3- If thrown byUnsafeBiConsumer.accept(Object,Object)
-
unchecked
public static <T,U, R uncheckedR> (T firstArgument, U secondArgument, UnsafeBiFunction<T, U, R> function) Gracefully applies anUnsafeBiFunction.Handles exceptions via
unchecked(Throwable).- Type Parameters:
T- first argument typeU- second argument typeR- result type- Parameters:
firstArgument- First argument toUnsafeBiFunction.apply(Object, Object)secondArgument- Second argument toUnsafeBiFunction.apply(Object, Object)function- AnyUnsafeFunction- Returns:
- result
-
checked
public static <T,U, R checkedR> (T firstArgument, U secondArgument, UnsafeBiFunction<T, U, throws ExceptionR> function) Gracefully applies anUnsafeBiFunction.Handles exceptions via
checked(Throwable).- Type Parameters:
T- first argument typeU- second argument typeR- result type- Parameters:
firstArgument- First argument toUnsafeBiFunction.apply(Object, Object)secondArgument- Second argument toUnsafeBiFunction.apply(Object, Object)function- AnyUnsafeBiFunction- Returns:
- result
- Throws:
Exception- If thrown byUnsafeBiFunction.apply(Object, Object)
-
checked
public static <T,U, R checkedR, T1 extends Exception> (Class<T1> expectedExceptionClass, T firstArgument, U secondArgument, UnsafeBiFunction<T, U, throws T1R> function) Gracefully applies anUnsafeBiFunction.Handles exceptions via
checked(Throwable, Class).- Type Parameters:
T- first argument typeU- second argument typeR- result typeT1- Expected exception type- Parameters:
expectedExceptionClass- Expected exception classfirstArgument- First argument toUnsafeBiFunction.apply(Object, Object)secondArgument- Second argument toUnsafeBiFunction.apply(Object, Object)function- AnyUnsafeBiFunction- Returns:
- result
- Throws:
T1- If thrown byUnsafeBiFunction.apply(Object, Object)
-
checked
public static <T,U, R checkedR, T1 extends Exception, T2 extends Exception> (Class<T1> expectedExceptionClass1, Class<T2> expectedExceptionClass2, T firstArgument, U secondArgument, UnsafeBiFunction<T, U, throws T1, T2R> function) Gracefully applies anUnsafeBiFunction.Handles exceptions via
checked(Throwable, Class, Class).- Type Parameters:
T- first argument typeU- second argument typeR- result typeT1- Expected exception typeT2- Expected exception type- Parameters:
expectedExceptionClass1- Expected exception classexpectedExceptionClass2- Expected exception classfirstArgument- First argument toUnsafeBiFunction.apply(Object, Object)secondArgument- Second argument toUnsafeBiFunction.apply(Object, Object)function- AnyUnsafeBiFunction- Returns:
- result
- Throws:
T1- If thrown byUnsafeBiFunction.apply(Object, Object)T2- If thrown byUnsafeBiFunction.apply(Object, Object)
-
checked
public static <T,U, R checkedR, T1 extends Exception, T2 extends Exception, T3 extends Exception> (Class<T1> expectedExceptionClass1, Class<T2> expectedExceptionClass2, Class<T3> expectedExceptionClass3, T firstArgument, U secondArgument, UnsafeBiFunction<T, U, throws T1, T2, T3R> function) Gracefully applies anUnsafeBiFunction.Handles exceptions via
checked(Throwable, Class, Class, Class).- Type Parameters:
T- first argument typeU- second argument typeR- result typeT1- Expected exception typeT2- Expected exception typeT3- Expected exception type- Parameters:
expectedExceptionClass1- Expected exception classexpectedExceptionClass2- Expected exception classexpectedExceptionClass3- Expected exception classfirstArgument- First argument toUnsafeBiFunction.apply(Object, Object)secondArgument- Second argument toUnsafeBiFunction.apply(Object, Object)function- AnyUnsafeBiFunction- Returns:
- result
- Throws:
T1- If thrown byUnsafeBiFunction.apply(Object, Object)T2- If thrown byUnsafeBiFunction.apply(Object, Object)T3- If thrown byUnsafeBiFunction.apply(Object, Object)
-
initialize
public static <T extends AutoCloseable,R> R initialize(T resource, UnsafeFunction<T, R> initializer) throws ExceptionGracefully initializes a component that depends on anAutoCloseableresource,closingthe resource and suppressing any close errors before rethrowing a checked exception if the component fails to initialize.If no exception or error is thrown by
initializer, then the resource remains open, and becomes the responsibility of the initialized component to close when finished with it.- Type Parameters:
T-AutoCloseableresource typeR-UnsafeFunctiondependent component type- Parameters:
resource- Open resourceinitializer-UnsafeFunctionfor initializing the resource- Returns:
resource, after successfully invokinginitializationConsumer- Throws:
Exception- If thrown from byinitializationConsumer
-
suppress
Runs anUnsafeRunnableand adds any exception thrown as suppressed by an another exception.This is useful for adding clean-up tasks to error handling routines related to failed initialization of closeable resources.
- Parameters:
throwable- Throwable that willsuppressexceptions thrown fromrunnable.runnable-UnsafeRunnable; will be run, and any exceptions thrown will be suppressed bythrowable- Returns:
- throwable if non-null; the exception thrown from runnable or null if no exception was thrown
-
suppress
Runs a sequence of tasks with error suppression.All tasks are guaranteed to run, but not guaranteed to finish. After all tasks have run, the first error encountered will be thrown; all additional errors will be suppressed.
- Parameters:
tasks- tasks to run- Throws:
Throwable- from the first task the fails in error
-
suppress
Runs a sequence of tasks with error suppression.All tasks are guaranteed to run, but not guaranteed to finish. After all tasks have run, the first error encountered will be thrown; all additional errors will be suppressed.
- Parameters:
tasks- tasks to run- Throws:
Throwable- from the first task the fails in error
-
trace
-