- java.lang.Object
-
- com.machinezoo.noexception.CheckedExceptionHandler
-
public abstract class CheckedExceptionHandler extends Object
Represents downgrading policy for checked exceptions. The exception policy is akin to a reusablecatchblock that catches checked exception and throws an unchecked one. Methodhandle(Exception)defines downgrading mechanism, typically by wrapping the checked exception in an unchecked one, but there are special cases likeExceptions.sneak(), which downgrade only method signature without altering the exception itself. Methods of this class apply the exception policy to functional interfaces (usually lambdas) by wrapping them in a try-catch block. See noexception tutorial.Typical usage:
Exceptions.sneak().get(() -> my_throwing_lambda)CheckedExceptionHandlerdoes not stop propagation of any exceptions (checked or unchecked).ExceptionHandleris used for that purpose. The two classes can be used together by first downgrading checked exceptions withCheckedExceptionHandlerand then applying exception handling policy withExceptionHandler.Combined usage:
Exceptions.silence().get(Exceptions.sneak().supplier(() -> my_throwing_lambda)).orElse(fallback)All wrapping methods surround the functional interface with a try-catch block. Only checked exceptions are handled. Unchecked exceptions are propagated to caller. If the functional interface throws checked exception, the exception is caught and passed to
handle(Exception), which converts it to an unchecked exception, which is then thrown.Wrapping methods for all standard functional interfaces are provided. Simple interfaces have short method names, like
runnable(ThrowingRunnable)orsupplier(ThrowingSupplier). Interfaces with longer names have methods that followfromXnaming pattern, for examplefromUnaryOperator(ThrowingUnaryOperator). Parameterless functional interfaces can be called directly by methodsrun(ThrowingRunnable),get(ThrowingSupplier), and the variousgetAsXvariants. All methods take throwing versions of standard functional interfaces, for exampleThrowingRunnableorThrowingSupplier.- See Also:
-
Tutorial,
handle(Exception),Exceptions,ExceptionHandler,ExceptionFilter
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedCheckedExceptionHandler()Initializes newCheckedExceptionHandler.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description CloseableScopecloseable(AutoCloseable closeable)Removes checked exceptions from method signature ofAutoCloseable.<T> Comparator<T>comparator(ThrowingComparator<T> comparator)Removes checked exceptions from method signature ofThrowingComparator.<T> Consumer<T>consumer(ThrowingConsumer<T> consumer)Removes checked exceptions from method signature ofThrowingConsumer.<T,U>
BiConsumer<T,U>fromBiConsumer(ThrowingBiConsumer<T,U> consumer)Removes checked exceptions from method signature ofThrowingBiConsumer.<T,U,R>
BiFunction<T,U,R>fromBiFunction(ThrowingBiFunction<T,U,R> function)Removes checked exceptions from method signature ofThrowingBiFunction.<T> BinaryOperator<T>fromBinaryOperator(ThrowingBinaryOperator<T> operator)Removes checked exceptions from method signature ofThrowingBinaryOperator.<T,U>
BiPredicate<T,U>fromBiPredicate(ThrowingBiPredicate<T,U> predicate)Removes checked exceptions from method signature ofThrowingBiPredicate.BooleanSupplierfromBooleanSupplier(ThrowingBooleanSupplier supplier)Removes checked exceptions from method signature ofThrowingBooleanSupplier.DoubleBinaryOperatorfromDoubleBinaryOperator(ThrowingDoubleBinaryOperator operator)Removes checked exceptions from method signature ofThrowingDoubleBinaryOperator.DoubleConsumerfromDoubleConsumer(ThrowingDoubleConsumer consumer)Removes checked exceptions from method signature ofThrowingDoubleConsumer.<R> DoubleFunction<R>fromDoubleFunction(ThrowingDoubleFunction<R> function)Removes checked exceptions from method signature ofThrowingDoubleFunction.DoublePredicatefromDoublePredicate(ThrowingDoublePredicate predicate)Removes checked exceptions from method signature ofThrowingDoublePredicate.DoubleSupplierfromDoubleSupplier(ThrowingDoubleSupplier supplier)Removes checked exceptions from method signature ofThrowingDoubleSupplier.DoubleToIntFunctionfromDoubleToIntFunction(ThrowingDoubleToIntFunction function)Removes checked exceptions from method signature ofThrowingDoubleToIntFunction.DoubleToLongFunctionfromDoubleToLongFunction(ThrowingDoubleToLongFunction function)Removes checked exceptions from method signature ofThrowingDoubleToLongFunction.DoubleUnaryOperatorfromDoubleUnaryOperator(ThrowingDoubleUnaryOperator operator)Removes checked exceptions from method signature ofThrowingDoubleUnaryOperator.IntBinaryOperatorfromIntBinaryOperator(ThrowingIntBinaryOperator operator)Removes checked exceptions from method signature ofThrowingIntBinaryOperator.IntConsumerfromIntConsumer(ThrowingIntConsumer consumer)Removes checked exceptions from method signature ofThrowingIntConsumer.<R> IntFunction<R>fromIntFunction(ThrowingIntFunction<R> function)Removes checked exceptions from method signature ofThrowingIntFunction.IntPredicatefromIntPredicate(ThrowingIntPredicate predicate)Removes checked exceptions from method signature ofThrowingIntPredicate.IntSupplierfromIntSupplier(ThrowingIntSupplier supplier)Removes checked exceptions from method signature ofThrowingIntSupplier.IntToDoubleFunctionfromIntToDoubleFunction(ThrowingIntToDoubleFunction function)Removes checked exceptions from method signature ofThrowingIntToDoubleFunction.IntToLongFunctionfromIntToLongFunction(ThrowingIntToLongFunction function)Removes checked exceptions from method signature ofThrowingIntToLongFunction.IntUnaryOperatorfromIntUnaryOperator(ThrowingIntUnaryOperator operator)Removes checked exceptions from method signature ofThrowingIntUnaryOperator.LongBinaryOperatorfromLongBinaryOperator(ThrowingLongBinaryOperator operator)Removes checked exceptions from method signature ofThrowingLongBinaryOperator.LongConsumerfromLongConsumer(ThrowingLongConsumer consumer)Removes checked exceptions from method signature ofThrowingLongConsumer.<R> LongFunction<R>fromLongFunction(ThrowingLongFunction<R> function)Removes checked exceptions from method signature ofThrowingLongFunction.LongPredicatefromLongPredicate(ThrowingLongPredicate predicate)Removes checked exceptions from method signature ofThrowingLongPredicate.LongSupplierfromLongSupplier(ThrowingLongSupplier supplier)Removes checked exceptions from method signature ofThrowingLongSupplier.LongToDoubleFunctionfromLongToDoubleFunction(ThrowingLongToDoubleFunction function)Removes checked exceptions from method signature ofThrowingLongToDoubleFunction.LongToIntFunctionfromLongToIntFunction(ThrowingLongToIntFunction function)Removes checked exceptions from method signature ofThrowingLongToIntFunction.LongUnaryOperatorfromLongUnaryOperator(ThrowingLongUnaryOperator operator)Removes checked exceptions from method signature ofThrowingLongUnaryOperator.<T> ObjDoubleConsumer<T>fromObjDoubleConsumer(ThrowingObjDoubleConsumer<T> consumer)Removes checked exceptions from method signature ofThrowingObjDoubleConsumer.<T> ObjIntConsumer<T>fromObjIntConsumer(ThrowingObjIntConsumer<T> consumer)Removes checked exceptions from method signature ofThrowingObjIntConsumer.<T> ObjLongConsumer<T>fromObjLongConsumer(ThrowingObjLongConsumer<T> consumer)Removes checked exceptions from method signature ofThrowingObjLongConsumer.<T,U>
ToDoubleBiFunction<T,U>fromToDoubleBiFunction(ThrowingToDoubleBiFunction<T,U> function)Removes checked exceptions from method signature ofThrowingToDoubleBiFunction.<T> ToDoubleFunction<T>fromToDoubleFunction(ThrowingToDoubleFunction<T> function)Removes checked exceptions from method signature ofThrowingToDoubleFunction.<T,U>
ToIntBiFunction<T,U>fromToIntBiFunction(ThrowingToIntBiFunction<T,U> function)Removes checked exceptions from method signature ofThrowingToIntBiFunction.<T> ToIntFunction<T>fromToIntFunction(ThrowingToIntFunction<T> function)Removes checked exceptions from method signature ofThrowingToIntFunction.<T,U>
ToLongBiFunction<T,U>fromToLongBiFunction(ThrowingToLongBiFunction<T,U> function)Removes checked exceptions from method signature ofThrowingToLongBiFunction.<T> ToLongFunction<T>fromToLongFunction(ThrowingToLongFunction<T> function)Removes checked exceptions from method signature ofThrowingToLongFunction.<T> UnaryOperator<T>fromUnaryOperator(ThrowingUnaryOperator<T> operator)Removes checked exceptions from method signature ofThrowingUnaryOperator.<T,R>
Function<T,R>function(ThrowingFunction<T,R> function)Removes checked exceptions from method signature ofThrowingFunction.<T> Tget(ThrowingSupplier<T> supplier)Filters out checked exceptions while runningThrowingSupplier.booleangetAsBoolean(ThrowingBooleanSupplier supplier)Filters out checked exceptions while runningThrowingBooleanSupplier.doublegetAsDouble(ThrowingDoubleSupplier supplier)Filters out checked exceptions while runningThrowingDoubleSupplier.intgetAsInt(ThrowingIntSupplier supplier)Filters out checked exceptions while runningThrowingIntSupplier.longgetAsLong(ThrowingLongSupplier supplier)Filters out checked exceptions while runningThrowingLongSupplier.abstract RuntimeExceptionhandle(Exception exception)Converts checked exception into an unchecked one.<T> Predicate<T>predicate(ThrowingPredicate<T> predicate)Removes checked exceptions from method signature ofThrowingPredicate.voidrun(ThrowingRunnable runnable)Filters out checked exceptions while runningThrowingRunnable.Runnablerunnable(ThrowingRunnable runnable)Removes checked exceptions from method signature ofThrowingRunnable.<T> Supplier<T>supplier(ThrowingSupplier<T> supplier)Removes checked exceptions from method signature ofThrowingSupplier.
-
-
-
Method Detail
-
handle
public abstract RuntimeException handle(Exception exception)
Converts checked exception into an unchecked one. This method must be defined in a derived class. Several implementations are provided by methods onExceptionsclass. All other methods of theCheckedExceptionHandlercall this method, but it can be also called directly.This method represents reusable catch block that handles all checked exceptions in the same way. When invoked, it must somehow convert the checked exception into an unchecked one, usually by wrapping it. Caller is then expected to throw the returned exception. There can be special cases like
Exceptions.sneak(), which don't return at all.Callers should not pass in
RuntimeExceptionor other unchecked exceptions. This method might erroneously wrap such exceptions as if they are checked exceptions. Methods of this class never pass unchecked exceptions to this method.- Parameters:
-
exception- checked exception to convert - Returns:
- converted unchecked exception
- Throws:
-
NullPointerException- ifexceptionisnull - See Also:
-
Tutorial,
Exceptions
-
runnable
public final Runnable runnable(ThrowingRunnable runnable)
Removes checked exceptions from method signature ofThrowingRunnable.If
runnablethrows a checked exception, the exception is caught and passed tohandle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Nullrunnableis silently wrapped and causesNullPointerExceptionwhen executed.Typical usage:
methodTakingRunnable(Exceptions.sneak().runnable(() -> my_throwing_lambda))- Parameters:
-
runnable- theThrowingRunnableto be converted, usually a lambda - Returns:
-
converted
Runnablefree of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
supplier
public final <T> Supplier<T> supplier(ThrowingSupplier<T> supplier)
Removes checked exceptions from method signature ofThrowingSupplier.If
supplierthrows a checked exception, the exception is caught and passed tohandle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Nullsupplieris silently wrapped and causesNullPointerExceptionwhen executed.Typical usage:
methodTakingSupplier(Exceptions.sneak().supplier(() -> my_throwing_lambda))- Type Parameters:
-
T- seeSupplier - Parameters:
-
supplier- theThrowingSupplierto be converted, usually a lambda - Returns:
-
converted
Supplierfree of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromIntSupplier
public final IntSupplier fromIntSupplier(ThrowingIntSupplier supplier)
Removes checked exceptions from method signature ofThrowingIntSupplier.If
supplierthrows a checked exception, the exception is caught and passed tohandle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Nullsupplieris silently wrapped and causesNullPointerExceptionwhen executed.Typical usage:
methodTakingIntSupplier(Exceptions.sneak().fromIntSupplier(() -> my_throwing_lambda))- Parameters:
-
supplier- theThrowingIntSupplierto be converted, usually a lambda - Returns:
-
converted
IntSupplierfree of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromLongSupplier
public final LongSupplier fromLongSupplier(ThrowingLongSupplier supplier)
Removes checked exceptions from method signature ofThrowingLongSupplier.If
supplierthrows a checked exception, the exception is caught and passed tohandle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Nullsupplieris silently wrapped and causesNullPointerExceptionwhen executed.Typical usage:
methodTakingLongSupplier(Exceptions.sneak().fromLongSupplier(() -> my_throwing_lambda))- Parameters:
-
supplier- theThrowingLongSupplierto be converted, usually a lambda - Returns:
-
converted
LongSupplierfree of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromDoubleSupplier
public final DoubleSupplier fromDoubleSupplier(ThrowingDoubleSupplier supplier)
Removes checked exceptions from method signature ofThrowingDoubleSupplier.If
supplierthrows a checked exception, the exception is caught and passed tohandle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Nullsupplieris silently wrapped and causesNullPointerExceptionwhen executed.Typical usage:
methodTakingDoubleSupplier(Exceptions.sneak().fromDoubleSupplier(() -> my_throwing_lambda))- Parameters:
-
supplier- theThrowingDoubleSupplierto be converted, usually a lambda - Returns:
-
converted
DoubleSupplierfree of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromBooleanSupplier
public final BooleanSupplier fromBooleanSupplier(ThrowingBooleanSupplier supplier)
Removes checked exceptions from method signature ofThrowingBooleanSupplier.If
supplierthrows a checked exception, the exception is caught and passed tohandle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Nullsupplieris silently wrapped and causesNullPointerExceptionwhen executed.Typical usage:
methodTakingBooleanSupplier(Exceptions.sneak().fromBooleanSupplier(() -> my_throwing_lambda))- Parameters:
-
supplier- theThrowingBooleanSupplierto be converted, usually a lambda - Returns:
-
converted
BooleanSupplierfree of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
consumer
public final <T> Consumer<T> consumer(ThrowingConsumer<T> consumer)
Removes checked exceptions from method signature ofThrowingConsumer.If
consumerthrows a checked exception, the exception is caught and passed tohandle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Nullconsumeris silently wrapped and causesNullPointerExceptionwhen executed.Typical usage:
methodTakingConsumer(Exceptions.sneak().consumer(t -> my_throwing_lambda))- Type Parameters:
-
T- seeConsumer - Parameters:
-
consumer- theThrowingConsumerto be converted, usually a lambda - Returns:
-
converted
Consumerfree of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromIntConsumer
public final IntConsumer fromIntConsumer(ThrowingIntConsumer consumer)
Removes checked exceptions from method signature ofThrowingIntConsumer.If
consumerthrows a checked exception, the exception is caught and passed tohandle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Nullconsumeris silently wrapped and causesNullPointerExceptionwhen executed.Typical usage:
methodTakingIntConsumer(Exceptions.sneak().fromIntConsumer(v -> my_throwing_lambda))- Parameters:
-
consumer- theThrowingIntConsumerto be converted, usually a lambda - Returns:
-
converted
IntConsumerfree of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromLongConsumer
public final LongConsumer fromLongConsumer(ThrowingLongConsumer consumer)
Removes checked exceptions from method signature ofThrowingLongConsumer.If
consumerthrows a checked exception, the exception is caught and passed tohandle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Nullconsumeris silently wrapped and causesNullPointerExceptionwhen executed.Typical usage:
methodTakingLongConsumer(Exceptions.sneak().fromLongConsumer(v -> my_throwing_lambda))- Parameters:
-
consumer- theThrowingLongConsumerto be converted, usually a lambda - Returns:
-
converted
LongConsumerfree of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromDoubleConsumer
public final DoubleConsumer fromDoubleConsumer(ThrowingDoubleConsumer consumer)
Removes checked exceptions from method signature ofThrowingDoubleConsumer.If
consumerthrows a checked exception, the exception is caught and passed tohandle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Nullconsumeris silently wrapped and causesNullPointerExceptionwhen executed.Typical usage:
methodTakingDoubleConsumer(Exceptions.sneak().fromDoubleConsumer(v -> my_throwing_lambda))- Parameters:
-
consumer- theThrowingDoubleConsumerto be converted, usually a lambda - Returns:
-
converted
DoubleConsumerfree of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromBiConsumer
public final <T,U> BiConsumer<T,U> fromBiConsumer(ThrowingBiConsumer<T,U> consumer)
Removes checked exceptions from method signature ofThrowingBiConsumer.If
consumerthrows a checked exception, the exception is caught and passed tohandle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Nullconsumeris silently wrapped and causesNullPointerExceptionwhen executed.Typical usage:
methodTakingBiConsumer(Exceptions.sneak().fromBiConsumer((t, u) -> my_throwing_lambda))- Type Parameters:
-
T- seeBiConsumer -
U- seeBiConsumer - Parameters:
-
consumer- theThrowingBiConsumerto be converted, usually a lambda - Returns:
-
converted
BiConsumerfree of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromObjIntConsumer
public final <T> ObjIntConsumer<T> fromObjIntConsumer(ThrowingObjIntConsumer<T> consumer)
Removes checked exceptions from method signature ofThrowingObjIntConsumer.If
consumerthrows a checked exception, the exception is caught and passed tohandle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Nullconsumeris silently wrapped and causesNullPointerExceptionwhen executed.Typical usage:
methodTakingObjIntConsumer(Exceptions.sneak().fromObjIntConsumer((t, v) -> my_throwing_lambda))- Type Parameters:
-
T- seeObjIntConsumer - Parameters:
-
consumer- theThrowingObjIntConsumerto be converted, usually a lambda - Returns:
-
converted
ObjIntConsumerfree of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromObjLongConsumer
public final <T> ObjLongConsumer<T> fromObjLongConsumer(ThrowingObjLongConsumer<T> consumer)
Removes checked exceptions from method signature ofThrowingObjLongConsumer.If
consumerthrows a checked exception, the exception is caught and passed tohandle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Nullconsumeris silently wrapped and causesNullPointerExceptionwhen executed.Typical usage:
methodTakingObjLongConsumer(Exceptions.sneak().fromObjLongConsumer((t, v) -> my_throwing_lambda))- Type Parameters:
-
T- seeObjLongConsumer - Parameters:
-
consumer- theThrowingObjLongConsumerto be converted, usually a lambda - Returns:
-
converted
ObjLongConsumerfree of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromObjDoubleConsumer
public final <T> ObjDoubleConsumer<T> fromObjDoubleConsumer(ThrowingObjDoubleConsumer<T> consumer)
Removes checked exceptions from method signature ofThrowingObjDoubleConsumer.If
consumerthrows a checked exception, the exception is caught and passed tohandle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Nullconsumeris silently wrapped and causesNullPointerExceptionwhen executed.Typical usage:
methodTakingObjDoubleConsumer(Exceptions.sneak().fromObjDoubleConsumer((t, v) -> my_throwing_lambda))- Type Parameters:
-
T- seeObjDoubleConsumer - Parameters:
-
consumer- theThrowingObjDoubleConsumerto be converted, usually a lambda - Returns:
-
converted
ObjDoubleConsumerfree of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
predicate
public final <T> Predicate<T> predicate(ThrowingPredicate<T> predicate)
Removes checked exceptions from method signature ofThrowingPredicate.If
predicatethrows a checked exception, the exception is caught and passed tohandle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Nullpredicateis silently wrapped and causesNullPointerExceptionwhen executed.Typical usage:
methodTakingPredicate(Exceptions.sneak().predicate(t -> my_throwing_lambda))- Type Parameters:
-
T- seePredicate - Parameters:
-
predicate- theThrowingPredicateto be converted, usually a lambda - Returns:
-
converted
Predicatefree of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromIntPredicate
public final IntPredicate fromIntPredicate(ThrowingIntPredicate predicate)
Removes checked exceptions from method signature ofThrowingIntPredicate.If
predicatethrows a checked exception, the exception is caught and passed tohandle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Nullpredicateis silently wrapped and causesNullPointerExceptionwhen executed.Typical usage:
methodTakingIntPredicate(Exceptions.sneak().fromIntPredicate(v -> my_throwing_lambda))- Parameters:
-
predicate- theThrowingIntPredicateto be converted, usually a lambda - Returns:
-
converted
IntPredicatefree of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromLongPredicate
public final LongPredicate fromLongPredicate(ThrowingLongPredicate predicate)
Removes checked exceptions from method signature ofThrowingLongPredicate.If
predicatethrows a checked exception, the exception is caught and passed tohandle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Nullpredicateis silently wrapped and causesNullPointerExceptionwhen executed.Typical usage:
methodTakingLongPredicate(Exceptions.sneak().fromLongPredicate(v -> my_throwing_lambda))- Parameters:
-
predicate- theThrowingLongPredicateto be converted, usually a lambda - Returns:
-
converted
LongPredicatefree of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromDoublePredicate
public final DoublePredicate fromDoublePredicate(ThrowingDoublePredicate predicate)
Removes checked exceptions from method signature ofThrowingDoublePredicate.If
predicatethrows a checked exception, the exception is caught and passed tohandle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Nullpredicateis silently wrapped and causesNullPointerExceptionwhen executed.Typical usage:
methodTakingDoublePredicate(Exceptions.sneak().fromDoublePredicate(v -> my_throwing_lambda))- Parameters:
-
predicate- theThrowingDoublePredicateto be converted, usually a lambda - Returns:
-
converted
DoublePredicatefree of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromBiPredicate
public final <T,U> BiPredicate<T,U> fromBiPredicate(ThrowingBiPredicate<T,U> predicate)
Removes checked exceptions from method signature ofThrowingBiPredicate.If
predicatethrows a checked exception, the exception is caught and passed tohandle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Nullpredicateis silently wrapped and causesNullPointerExceptionwhen executed.Typical usage:
methodTakingBiPredicate(Exceptions.sneak().fromBiPredicate((t, u) -> my_throwing_lambda))- Type Parameters:
-
T- seeBiPredicate -
U- seeBiPredicate - Parameters:
-
predicate- theThrowingBiPredicateto be converted, usually a lambda - Returns:
-
converted
BiPredicatefree of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
function
public final <T,R> Function<T,R> function(ThrowingFunction<T,R> function)
Removes checked exceptions from method signature ofThrowingFunction.If
functionthrows a checked exception, the exception is caught and passed tohandle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Nullfunctionis silently wrapped and causesNullPointerExceptionwhen executed.Typical usage:
methodTakingFunction(Exceptions.sneak().function(t -> my_throwing_lambda))- Type Parameters:
-
T- seeFunction -
R- seeFunction - Parameters:
-
function- theThrowingFunctionto be converted, usually a lambda - Returns:
-
converted
Functionfree of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromToIntFunction
public final <T> ToIntFunction<T> fromToIntFunction(ThrowingToIntFunction<T> function)
Removes checked exceptions from method signature ofThrowingToIntFunction.If
functionthrows a checked exception, the exception is caught and passed tohandle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Nullfunctionis silently wrapped and causesNullPointerExceptionwhen executed.Typical usage:
methodTakingToIntFunction(Exceptions.sneak().fromToIntFunction(v -> my_throwing_lambda))- Type Parameters:
-
T- seeToIntFunction - Parameters:
-
function- theThrowingToIntFunctionto be converted, usually a lambda - Returns:
-
converted
ToIntFunctionfree of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromIntFunction
public final <R> IntFunction<R> fromIntFunction(ThrowingIntFunction<R> function)
Removes checked exceptions from method signature ofThrowingIntFunction.If
functionthrows a checked exception, the exception is caught and passed tohandle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Nullfunctionis silently wrapped and causesNullPointerExceptionwhen executed.Typical usage:
methodTakingIntFunction(Exceptions.sneak().fromIntFunction(v -> my_throwing_lambda))- Type Parameters:
-
R- seeIntFunction - Parameters:
-
function- theThrowingIntFunctionto be converted, usually a lambda - Returns:
-
converted
IntFunctionfree of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromIntToLongFunction
public final IntToLongFunction fromIntToLongFunction(ThrowingIntToLongFunction function)
Removes checked exceptions from method signature ofThrowingIntToLongFunction.If
functionthrows a checked exception, the exception is caught and passed tohandle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Nullfunctionis silently wrapped and causesNullPointerExceptionwhen executed.Typical usage:
methodTakingIntToLongFunction(Exceptions.sneak().fromIntToLongFunction(v -> my_throwing_lambda))- Parameters:
-
function- theThrowingIntToLongFunctionto be converted, usually a lambda - Returns:
-
converted
IntToLongFunctionfree of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromIntToDoubleFunction
public final IntToDoubleFunction fromIntToDoubleFunction(ThrowingIntToDoubleFunction function)
Removes checked exceptions from method signature ofThrowingIntToDoubleFunction.If
functionthrows a checked exception, the exception is caught and passed tohandle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Nullfunctionis silently wrapped and causesNullPointerExceptionwhen executed.Typical usage:
methodTakingIntToDoubleFunction(Exceptions.sneak().fromIntToDoubleFunction(v -> my_throwing_lambda))- Parameters:
-
function- theThrowingIntToDoubleFunctionto be converted, usually a lambda - Returns:
-
converted
IntToDoubleFunctionfree of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromToLongFunction
public final <T> ToLongFunction<T> fromToLongFunction(ThrowingToLongFunction<T> function)
Removes checked exceptions from method signature ofThrowingToLongFunction.If
functionthrows a checked exception, the exception is caught and passed tohandle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Nullfunctionis silently wrapped and causesNullPointerExceptionwhen executed.Typical usage:
methodTakingToLongFunction(Exceptions.sneak().fromToLongFunction(v -> my_throwing_lambda))- Type Parameters:
-
T- seeToLongFunction - Parameters:
-
function- theThrowingToLongFunctionto be converted, usually a lambda - Returns:
-
converted
ToLongFunctionfree of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromLongFunction
public final <R> LongFunction<R> fromLongFunction(ThrowingLongFunction<R> function)
Removes checked exceptions from method signature ofThrowingLongFunction.If
functionthrows a checked exception, the exception is caught and passed tohandle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Nullfunctionis silently wrapped and causesNullPointerExceptionwhen executed.Typical usage:
methodTakingLongFunction(Exceptions.sneak().fromLongFunction(v -> my_throwing_lambda))- Type Parameters:
-
R- seeLongFunction - Parameters:
-
function- theThrowingLongFunctionto be converted, usually a lambda - Returns:
-
converted
LongFunctionfree of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromLongToIntFunction
public final LongToIntFunction fromLongToIntFunction(ThrowingLongToIntFunction function)
Removes checked exceptions from method signature ofThrowingLongToIntFunction.If
functionthrows a checked exception, the exception is caught and passed tohandle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Nullfunctionis silently wrapped and causesNullPointerExceptionwhen executed.Typical usage:
methodTakingLongToIntFunction(Exceptions.sneak().fromLongToIntFunction(v -> my_throwing_lambda))- Parameters:
-
function- theThrowingLongToIntFunctionto be converted, usually a lambda - Returns:
-
converted
LongToIntFunctionfree of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromLongToDoubleFunction
public final LongToDoubleFunction fromLongToDoubleFunction(ThrowingLongToDoubleFunction function)
Removes checked exceptions from method signature ofThrowingLongToDoubleFunction.If
functionthrows a checked exception, the exception is caught and passed tohandle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Nullfunctionis silently wrapped and causesNullPointerExceptionwhen executed.Typical usage:
methodTakingLongToDoubleFunction(Exceptions.sneak().fromLongToDoubleFunction(v -> my_throwing_lambda))- Parameters:
-
function- theThrowingLongToDoubleFunctionto be converted, usually a lambda - Returns:
-
converted
LongToDoubleFunctionfree of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromToDoubleFunction
public final <T> ToDoubleFunction<T> fromToDoubleFunction(ThrowingToDoubleFunction<T> function)
Removes checked exceptions from method signature ofThrowingToDoubleFunction.If
functionthrows a checked exception, the exception is caught and passed tohandle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Nullfunctionis silently wrapped and causesNullPointerExceptionwhen executed.Typical usage:
methodTakingToDoubleFunction(Exceptions.sneak().fromToDoubleFunction(v -> my_throwing_lambda))- Type Parameters:
-
T- seeToDoubleFunction - Parameters:
-
function- theThrowingToDoubleFunctionto be converted, usually a lambda - Returns:
-
converted
ToDoubleFunctionfree of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromDoubleFunction
public final <R> DoubleFunction<R> fromDoubleFunction(ThrowingDoubleFunction<R> function)
Removes checked exceptions from method signature ofThrowingDoubleFunction.If
functionthrows a checked exception, the exception is caught and passed tohandle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Nullfunctionis silently wrapped and causesNullPointerExceptionwhen executed.Typical usage:
methodTakingDoubleFunction(Exceptions.sneak().fromDoubleFunction(v -> my_throwing_lambda))- Type Parameters:
-
R- seeDoubleFunction - Parameters:
-
function- theThrowingDoubleFunctionto be converted, usually a lambda - Returns:
-
converted
DoubleFunctionfree of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromDoubleToIntFunction
public final DoubleToIntFunction fromDoubleToIntFunction(ThrowingDoubleToIntFunction function)
Removes checked exceptions from method signature ofThrowingDoubleToIntFunction.If
functionthrows a checked exception, the exception is caught and passed tohandle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Nullfunctionis silently wrapped and causesNullPointerExceptionwhen executed.Typical usage:
methodTakingDoubleToIntFunction(Exceptions.sneak().fromDoubleToIntFunction(v -> my_throwing_lambda))- Parameters:
-
function- theThrowingDoubleToIntFunctionto be converted, usually a lambda - Returns:
-
converted
DoubleToIntFunctionfree of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromDoubleToLongFunction
public final DoubleToLongFunction fromDoubleToLongFunction(ThrowingDoubleToLongFunction function)
Removes checked exceptions from method signature ofThrowingDoubleToLongFunction.If
functionthrows a checked exception, the exception is caught and passed tohandle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Nullfunctionis silently wrapped and causesNullPointerExceptionwhen executed.Typical usage:
methodTakingDoubleToLongFunction(Exceptions.sneak().fromDoubleToLongFunction(v -> my_throwing_lambda))- Parameters:
-
function- theThrowingDoubleToLongFunctionto be converted, usually a lambda - Returns:
-
converted
DoubleToLongFunctionfree of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromUnaryOperator
public final <T> UnaryOperator<T> fromUnaryOperator(ThrowingUnaryOperator<T> operator)
Removes checked exceptions from method signature ofThrowingUnaryOperator.If
operatorthrows a checked exception, the exception is caught and passed tohandle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Nulloperatoris silently wrapped and causesNullPointerExceptionwhen executed.Typical usage:
methodTakingUnaryOperator(Exceptions.sneak().fromUnaryOperator(o -> my_throwing_lambda))- Type Parameters:
-
T- seeUnaryOperator - Parameters:
-
operator- theThrowingUnaryOperatorto be converted, usually a lambda - Returns:
-
converted
UnaryOperatorfree of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromIntUnaryOperator
public final IntUnaryOperator fromIntUnaryOperator(ThrowingIntUnaryOperator operator)
Removes checked exceptions from method signature ofThrowingIntUnaryOperator.If
operatorthrows a checked exception, the exception is caught and passed tohandle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Nulloperatoris silently wrapped and causesNullPointerExceptionwhen executed.Typical usage:
methodTakingIntUnaryOperator(Exceptions.sneak().fromIntUnaryOperator(o -> my_throwing_lambda))- Parameters:
-
operator- theThrowingIntUnaryOperatorto be converted, usually a lambda - Returns:
-
converted
IntUnaryOperatorfree of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromLongUnaryOperator
public final LongUnaryOperator fromLongUnaryOperator(ThrowingLongUnaryOperator operator)
Removes checked exceptions from method signature ofThrowingLongUnaryOperator.If
operatorthrows a checked exception, the exception is caught and passed tohandle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Nulloperatoris silently wrapped and causesNullPointerExceptionwhen executed.Typical usage:
methodTakingLongUnaryOperator(Exceptions.sneak().fromLongUnaryOperator(o -> my_throwing_lambda))- Parameters:
-
operator- theThrowingLongUnaryOperatorto be converted, usually a lambda - Returns:
-
converted
LongUnaryOperatorfree of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromDoubleUnaryOperator
public final DoubleUnaryOperator fromDoubleUnaryOperator(ThrowingDoubleUnaryOperator operator)
Removes checked exceptions from method signature ofThrowingDoubleUnaryOperator.If
operatorthrows a checked exception, the exception is caught and passed tohandle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Nulloperatoris silently wrapped and causesNullPointerExceptionwhen executed.Typical usage:
methodTakingDoubleUnaryOperator(Exceptions.sneak().fromDoubleUnaryOperator(o -> my_throwing_lambda))- Parameters:
-
operator- theThrowingDoubleUnaryOperatorto be converted, usually a lambda - Returns:
-
converted
DoubleUnaryOperatorfree of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromBiFunction
public final <T,U,R> BiFunction<T,U,R> fromBiFunction(ThrowingBiFunction<T,U,R> function)
Removes checked exceptions from method signature ofThrowingBiFunction.If
functionthrows a checked exception, the exception is caught and passed tohandle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Nullfunctionis silently wrapped and causesNullPointerExceptionwhen executed.Typical usage:
methodTakingBiFunction(Exceptions.sneak().fromBiFunction((t, u) -> my_throwing_lambda))- Type Parameters:
-
T- seeBiFunction -
U- seeBiFunction -
R- seeBiFunction - Parameters:
-
function- theThrowingBiFunctionto be converted, usually a lambda - Returns:
-
converted
BiFunctionfree of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromToIntBiFunction
public final <T,U> ToIntBiFunction<T,U> fromToIntBiFunction(ThrowingToIntBiFunction<T,U> function)
Removes checked exceptions from method signature ofThrowingToIntBiFunction.If
functionthrows a checked exception, the exception is caught and passed tohandle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Nullfunctionis silently wrapped and causesNullPointerExceptionwhen executed.Typical usage:
methodTakingToIntBiFunction(Exceptions.sneak().fromToIntBiFunction((t, u) -> my_throwing_lambda))- Type Parameters:
-
T- seeToIntBiFunction -
U- seeToIntBiFunction - Parameters:
-
function- theThrowingToIntBiFunctionto be converted, usually a lambda - Returns:
-
converted
ToIntBiFunctionfree of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromToLongBiFunction
public final <T,U> ToLongBiFunction<T,U> fromToLongBiFunction(ThrowingToLongBiFunction<T,U> function)
Removes checked exceptions from method signature ofThrowingToLongBiFunction.If
functionthrows a checked exception, the exception is caught and passed tohandle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Nullfunctionis silently wrapped and causesNullPointerExceptionwhen executed.Typical usage:
methodTakingToLongBiFunction(Exceptions.sneak().fromToLongBiFunction((t, u) -> my_throwing_lambda))- Type Parameters:
-
T- seeToLongBiFunction -
U- seeToLongBiFunction - Parameters:
-
function- theThrowingToLongBiFunctionto be converted, usually a lambda - Returns:
-
converted
ToLongBiFunctionfree of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromToDoubleBiFunction
public final <T,U> ToDoubleBiFunction<T,U> fromToDoubleBiFunction(ThrowingToDoubleBiFunction<T,U> function)
Removes checked exceptions from method signature ofThrowingToDoubleBiFunction.If
functionthrows a checked exception, the exception is caught and passed tohandle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Nullfunctionis silently wrapped and causesNullPointerExceptionwhen executed.Typical usage:
methodTakingToDoubleBiFunction(Exceptions.sneak().fromToDoubleBiFunction((t, u) -> my_throwing_lambda))- Type Parameters:
-
T- seeToDoubleBiFunction -
U- seeToDoubleBiFunction - Parameters:
-
function- theThrowingToDoubleBiFunctionto be converted, usually a lambda - Returns:
-
converted
ToDoubleBiFunctionfree of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromBinaryOperator
public final <T> BinaryOperator<T> fromBinaryOperator(ThrowingBinaryOperator<T> operator)
Removes checked exceptions from method signature ofThrowingBinaryOperator.If
operatorthrows a checked exception, the exception is caught and passed tohandle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Nulloperatoris silently wrapped and causesNullPointerExceptionwhen executed.Typical usage:
methodTakingBinaryOperator(Exceptions.sneak().fromBinaryOperator((l, r) -> my_throwing_lambda))- Type Parameters:
-
T- seeBinaryOperator - Parameters:
-
operator- theThrowingBinaryOperatorto be converted, usually a lambda - Returns:
-
converted
BinaryOperatorfree of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromIntBinaryOperator
public final IntBinaryOperator fromIntBinaryOperator(ThrowingIntBinaryOperator operator)
Removes checked exceptions from method signature ofThrowingIntBinaryOperator.If
operatorthrows a checked exception, the exception is caught and passed tohandle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Nulloperatoris silently wrapped and causesNullPointerExceptionwhen executed.Typical usage:
methodTakingIntBinaryOperator(Exceptions.sneak().fromIntBinaryOperator((l, r) -> my_throwing_lambda))- Parameters:
-
operator- theThrowingIntBinaryOperatorto be converted, usually a lambda - Returns:
-
converted
IntBinaryOperatorfree of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromLongBinaryOperator
public final LongBinaryOperator fromLongBinaryOperator(ThrowingLongBinaryOperator operator)
Removes checked exceptions from method signature ofThrowingLongBinaryOperator.If
operatorthrows a checked exception, the exception is caught and passed tohandle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Nulloperatoris silently wrapped and causesNullPointerExceptionwhen executed.Typical usage:
methodTakingLongBinaryOperator(Exceptions.sneak().fromLongBinaryOperator((l, r) -> my_throwing_lambda))- Parameters:
-
operator- theThrowingLongBinaryOperatorto be converted, usually a lambda - Returns:
-
converted
LongBinaryOperatorfree of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromDoubleBinaryOperator
public final DoubleBinaryOperator fromDoubleBinaryOperator(ThrowingDoubleBinaryOperator operator)
Removes checked exceptions from method signature ofThrowingDoubleBinaryOperator.If
operatorthrows a checked exception, the exception is caught and passed tohandle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Nulloperatoris silently wrapped and causesNullPointerExceptionwhen executed.Typical usage:
methodTakingDoubleBinaryOperator(Exceptions.sneak().fromDoubleBinaryOperator((l, r) -> my_throwing_lambda))- Parameters:
-
operator- theThrowingDoubleBinaryOperatorto be converted, usually a lambda - Returns:
-
converted
DoubleBinaryOperatorfree of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
comparator
public final <T> Comparator<T> comparator(ThrowingComparator<T> comparator)
Removes checked exceptions from method signature ofThrowingComparator.If
comparatorthrows a checked exception, the exception is caught and passed tohandle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Nullcomparatoris silently wrapped and causesNullPointerExceptionwhen executed.Typical usage:
methodTakingComparator(Exceptions.sneak().comparator((l, r) -> my_throwing_lambda))- Type Parameters:
-
T- seeComparator - Parameters:
-
comparator- theThrowingComparatorto be converted, usually a lambda - Returns:
-
converted
Comparatorfree of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
closeable
public final CloseableScope closeable(AutoCloseable closeable)
Removes checked exceptions from method signature ofAutoCloseable.If
closeablethrows a checked exception, the exception is caught and passed tohandle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method. Nullcloseableis silently wrapped and causesNullPointerExceptionwhen executed.Typical usage:
try (var scope = Exceptions.sneak().closeable(openSomething()))- Parameters:
-
closeable- theAutoCloseableto be converted - Returns:
-
converted
CloseableScopefree of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
run
public final void run(ThrowingRunnable runnable)
Filters out checked exceptions while runningThrowingRunnable.If
runnablethrows a checked exception, the exception is caught and passed tohandle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method.Typical usage:
Exceptions.sneak().run(() -> my_throwing_lambda))- Parameters:
-
runnable- theThrowingRunnableto run, usually a lambda - Throws:
-
NullPointerException- ifrunnableisnull - See Also:
-
Tutorial,
Exceptions
-
get
public final <T> T get(ThrowingSupplier<T> supplier)
Filters out checked exceptions while runningThrowingSupplier.If
supplierthrows a checked exception, the exception is caught and passed tohandle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method.Typical usage:
Exceptions.sneak().get(() -> my_throwing_lambda))- Type Parameters:
-
T- seeSupplier - Parameters:
-
supplier- theThrowingSupplierto run, usually a lambda - Returns:
-
value returned from
supplier - Throws:
-
NullPointerException- ifsupplierisnull - See Also:
-
Tutorial,
Exceptions
-
getAsInt
public final int getAsInt(ThrowingIntSupplier supplier)
Filters out checked exceptions while runningThrowingIntSupplier.If
supplierthrows a checked exception, the exception is caught and passed tohandle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method.Typical usage:
Exceptions.sneak().getAsInt(() -> my_throwing_lambda))- Parameters:
-
supplier- theThrowingIntSupplierto run, usually a lambda - Returns:
-
value returned from
supplier - Throws:
-
NullPointerException- ifsupplierisnull - See Also:
-
Tutorial,
Exceptions
-
getAsLong
public final long getAsLong(ThrowingLongSupplier supplier)
Filters out checked exceptions while runningThrowingLongSupplier.If
supplierthrows a checked exception, the exception is caught and passed tohandle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method.Typical usage:
Exceptions.sneak().getAsLong(() -> my_throwing_lambda))- Parameters:
-
supplier- theThrowingLongSupplierto run, usually a lambda - Returns:
-
value returned from
supplier - Throws:
-
NullPointerException- ifsupplierisnull - See Also:
-
Tutorial,
Exceptions
-
getAsDouble
public final double getAsDouble(ThrowingDoubleSupplier supplier)
Filters out checked exceptions while runningThrowingDoubleSupplier.If
supplierthrows a checked exception, the exception is caught and passed tohandle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method.Typical usage:
Exceptions.sneak().getAsDouble(() -> my_throwing_lambda))- Parameters:
-
supplier- theThrowingDoubleSupplierto run, usually a lambda - Returns:
-
value returned from
supplier - Throws:
-
NullPointerException- ifsupplierisnull - See Also:
-
Tutorial,
Exceptions
-
getAsBoolean
public final boolean getAsBoolean(ThrowingBooleanSupplier supplier)
Filters out checked exceptions while runningThrowingBooleanSupplier.If
supplierthrows a checked exception, the exception is caught and passed tohandle(Exception), which usually converts it to an unchecked exception, which is then thrown by this method.Typical usage:
Exceptions.sneak().getAsBoolean(() -> my_throwing_lambda))- Parameters:
-
supplier- theThrowingBooleanSupplierto run, usually a lambda - Returns:
-
value returned from
supplier - Throws:
-
NullPointerException- ifsupplierisnull - See Also:
-
Tutorial,
Exceptions
-
-