- 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 reusablecatch
block 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)
CheckedExceptionHandler
does not stop propagation of any exceptions (checked or unchecked).ExceptionHandler
is used for that purpose. The two classes can be used together by first downgrading checked exceptions withCheckedExceptionHandler
and 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 followfromX
naming pattern, for examplefromUnaryOperator(ThrowingUnaryOperator)
. Parameterless functional interfaces can be called directly by methodsrun(ThrowingRunnable)
,get(ThrowingSupplier)
, and the variousgetAsX
variants. All methods take throwing versions of standard functional interfaces, for exampleThrowingRunnable
orThrowingSupplier
.- See Also:
-
Tutorial,
handle(Exception)
,Exceptions
,ExceptionHandler
,ExceptionFilter
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
CheckedExceptionHandler()
Initializes newCheckedExceptionHandler
.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description CloseableScope
closeable(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
.BooleanSupplier
fromBooleanSupplier(ThrowingBooleanSupplier supplier)
Removes checked exceptions from method signature ofThrowingBooleanSupplier
.DoubleBinaryOperator
fromDoubleBinaryOperator(ThrowingDoubleBinaryOperator operator)
Removes checked exceptions from method signature ofThrowingDoubleBinaryOperator
.DoubleConsumer
fromDoubleConsumer(ThrowingDoubleConsumer consumer)
Removes checked exceptions from method signature ofThrowingDoubleConsumer
.<R> DoubleFunction<R>
fromDoubleFunction(ThrowingDoubleFunction<R> function)
Removes checked exceptions from method signature ofThrowingDoubleFunction
.DoublePredicate
fromDoublePredicate(ThrowingDoublePredicate predicate)
Removes checked exceptions from method signature ofThrowingDoublePredicate
.DoubleSupplier
fromDoubleSupplier(ThrowingDoubleSupplier supplier)
Removes checked exceptions from method signature ofThrowingDoubleSupplier
.DoubleToIntFunction
fromDoubleToIntFunction(ThrowingDoubleToIntFunction function)
Removes checked exceptions from method signature ofThrowingDoubleToIntFunction
.DoubleToLongFunction
fromDoubleToLongFunction(ThrowingDoubleToLongFunction function)
Removes checked exceptions from method signature ofThrowingDoubleToLongFunction
.DoubleUnaryOperator
fromDoubleUnaryOperator(ThrowingDoubleUnaryOperator operator)
Removes checked exceptions from method signature ofThrowingDoubleUnaryOperator
.IntBinaryOperator
fromIntBinaryOperator(ThrowingIntBinaryOperator operator)
Removes checked exceptions from method signature ofThrowingIntBinaryOperator
.IntConsumer
fromIntConsumer(ThrowingIntConsumer consumer)
Removes checked exceptions from method signature ofThrowingIntConsumer
.<R> IntFunction<R>
fromIntFunction(ThrowingIntFunction<R> function)
Removes checked exceptions from method signature ofThrowingIntFunction
.IntPredicate
fromIntPredicate(ThrowingIntPredicate predicate)
Removes checked exceptions from method signature ofThrowingIntPredicate
.IntSupplier
fromIntSupplier(ThrowingIntSupplier supplier)
Removes checked exceptions from method signature ofThrowingIntSupplier
.IntToDoubleFunction
fromIntToDoubleFunction(ThrowingIntToDoubleFunction function)
Removes checked exceptions from method signature ofThrowingIntToDoubleFunction
.IntToLongFunction
fromIntToLongFunction(ThrowingIntToLongFunction function)
Removes checked exceptions from method signature ofThrowingIntToLongFunction
.IntUnaryOperator
fromIntUnaryOperator(ThrowingIntUnaryOperator operator)
Removes checked exceptions from method signature ofThrowingIntUnaryOperator
.LongBinaryOperator
fromLongBinaryOperator(ThrowingLongBinaryOperator operator)
Removes checked exceptions from method signature ofThrowingLongBinaryOperator
.LongConsumer
fromLongConsumer(ThrowingLongConsumer consumer)
Removes checked exceptions from method signature ofThrowingLongConsumer
.<R> LongFunction<R>
fromLongFunction(ThrowingLongFunction<R> function)
Removes checked exceptions from method signature ofThrowingLongFunction
.LongPredicate
fromLongPredicate(ThrowingLongPredicate predicate)
Removes checked exceptions from method signature ofThrowingLongPredicate
.LongSupplier
fromLongSupplier(ThrowingLongSupplier supplier)
Removes checked exceptions from method signature ofThrowingLongSupplier
.LongToDoubleFunction
fromLongToDoubleFunction(ThrowingLongToDoubleFunction function)
Removes checked exceptions from method signature ofThrowingLongToDoubleFunction
.LongToIntFunction
fromLongToIntFunction(ThrowingLongToIntFunction function)
Removes checked exceptions from method signature ofThrowingLongToIntFunction
.LongUnaryOperator
fromLongUnaryOperator(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> T
get(ThrowingSupplier<T> supplier)
Filters out checked exceptions while runningThrowingSupplier
.boolean
getAsBoolean(ThrowingBooleanSupplier supplier)
Filters out checked exceptions while runningThrowingBooleanSupplier
.double
getAsDouble(ThrowingDoubleSupplier supplier)
Filters out checked exceptions while runningThrowingDoubleSupplier
.int
getAsInt(ThrowingIntSupplier supplier)
Filters out checked exceptions while runningThrowingIntSupplier
.long
getAsLong(ThrowingLongSupplier supplier)
Filters out checked exceptions while runningThrowingLongSupplier
.abstract RuntimeException
handle(Exception exception)
Converts checked exception into an unchecked one.<T> Predicate<T>
predicate(ThrowingPredicate<T> predicate)
Removes checked exceptions from method signature ofThrowingPredicate
.void
run(ThrowingRunnable runnable)
Filters out checked exceptions while runningThrowingRunnable
.Runnable
runnable(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 onExceptions
class. All other methods of theCheckedExceptionHandler
call 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
RuntimeException
or 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
- ifexception
isnull
- See Also:
-
Tutorial,
Exceptions
-
runnable
public final Runnable runnable(ThrowingRunnable runnable)
Removes checked exceptions from method signature ofThrowingRunnable
.If
runnable
throws 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. Nullrunnable
is silently wrapped and causesNullPointerException
when executed.Typical usage:
methodTakingRunnable(Exceptions.sneak().runnable(() -> my_throwing_lambda))
- Parameters:
-
runnable
- theThrowingRunnable
to be converted, usually a lambda - Returns:
-
converted
Runnable
free 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
supplier
throws 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. Nullsupplier
is silently wrapped and causesNullPointerException
when executed.Typical usage:
methodTakingSupplier(Exceptions.sneak().supplier(() -> my_throwing_lambda))
- Type Parameters:
-
T
- seeSupplier
- Parameters:
-
supplier
- theThrowingSupplier
to be converted, usually a lambda - Returns:
-
converted
Supplier
free of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromIntSupplier
public final IntSupplier fromIntSupplier(ThrowingIntSupplier supplier)
Removes checked exceptions from method signature ofThrowingIntSupplier
.If
supplier
throws 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. Nullsupplier
is silently wrapped and causesNullPointerException
when executed.Typical usage:
methodTakingIntSupplier(Exceptions.sneak().fromIntSupplier(() -> my_throwing_lambda))
- Parameters:
-
supplier
- theThrowingIntSupplier
to be converted, usually a lambda - Returns:
-
converted
IntSupplier
free of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromLongSupplier
public final LongSupplier fromLongSupplier(ThrowingLongSupplier supplier)
Removes checked exceptions from method signature ofThrowingLongSupplier
.If
supplier
throws 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. Nullsupplier
is silently wrapped and causesNullPointerException
when executed.Typical usage:
methodTakingLongSupplier(Exceptions.sneak().fromLongSupplier(() -> my_throwing_lambda))
- Parameters:
-
supplier
- theThrowingLongSupplier
to be converted, usually a lambda - Returns:
-
converted
LongSupplier
free of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromDoubleSupplier
public final DoubleSupplier fromDoubleSupplier(ThrowingDoubleSupplier supplier)
Removes checked exceptions from method signature ofThrowingDoubleSupplier
.If
supplier
throws 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. Nullsupplier
is silently wrapped and causesNullPointerException
when executed.Typical usage:
methodTakingDoubleSupplier(Exceptions.sneak().fromDoubleSupplier(() -> my_throwing_lambda))
- Parameters:
-
supplier
- theThrowingDoubleSupplier
to be converted, usually a lambda - Returns:
-
converted
DoubleSupplier
free of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromBooleanSupplier
public final BooleanSupplier fromBooleanSupplier(ThrowingBooleanSupplier supplier)
Removes checked exceptions from method signature ofThrowingBooleanSupplier
.If
supplier
throws 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. Nullsupplier
is silently wrapped and causesNullPointerException
when executed.Typical usage:
methodTakingBooleanSupplier(Exceptions.sneak().fromBooleanSupplier(() -> my_throwing_lambda))
- Parameters:
-
supplier
- theThrowingBooleanSupplier
to be converted, usually a lambda - Returns:
-
converted
BooleanSupplier
free 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
consumer
throws 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. Nullconsumer
is silently wrapped and causesNullPointerException
when executed.Typical usage:
methodTakingConsumer(Exceptions.sneak().consumer(t -> my_throwing_lambda))
- Type Parameters:
-
T
- seeConsumer
- Parameters:
-
consumer
- theThrowingConsumer
to be converted, usually a lambda - Returns:
-
converted
Consumer
free of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromIntConsumer
public final IntConsumer fromIntConsumer(ThrowingIntConsumer consumer)
Removes checked exceptions from method signature ofThrowingIntConsumer
.If
consumer
throws 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. Nullconsumer
is silently wrapped and causesNullPointerException
when executed.Typical usage:
methodTakingIntConsumer(Exceptions.sneak().fromIntConsumer(v -> my_throwing_lambda))
- Parameters:
-
consumer
- theThrowingIntConsumer
to be converted, usually a lambda - Returns:
-
converted
IntConsumer
free of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromLongConsumer
public final LongConsumer fromLongConsumer(ThrowingLongConsumer consumer)
Removes checked exceptions from method signature ofThrowingLongConsumer
.If
consumer
throws 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. Nullconsumer
is silently wrapped and causesNullPointerException
when executed.Typical usage:
methodTakingLongConsumer(Exceptions.sneak().fromLongConsumer(v -> my_throwing_lambda))
- Parameters:
-
consumer
- theThrowingLongConsumer
to be converted, usually a lambda - Returns:
-
converted
LongConsumer
free of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromDoubleConsumer
public final DoubleConsumer fromDoubleConsumer(ThrowingDoubleConsumer consumer)
Removes checked exceptions from method signature ofThrowingDoubleConsumer
.If
consumer
throws 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. Nullconsumer
is silently wrapped and causesNullPointerException
when executed.Typical usage:
methodTakingDoubleConsumer(Exceptions.sneak().fromDoubleConsumer(v -> my_throwing_lambda))
- Parameters:
-
consumer
- theThrowingDoubleConsumer
to be converted, usually a lambda - Returns:
-
converted
DoubleConsumer
free 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
consumer
throws 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. Nullconsumer
is silently wrapped and causesNullPointerException
when executed.Typical usage:
methodTakingBiConsumer(Exceptions.sneak().fromBiConsumer((t, u) -> my_throwing_lambda))
- Type Parameters:
-
T
- seeBiConsumer
-
U
- seeBiConsumer
- Parameters:
-
consumer
- theThrowingBiConsumer
to be converted, usually a lambda - Returns:
-
converted
BiConsumer
free 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
consumer
throws 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. Nullconsumer
is silently wrapped and causesNullPointerException
when executed.Typical usage:
methodTakingObjIntConsumer(Exceptions.sneak().fromObjIntConsumer((t, v) -> my_throwing_lambda))
- Type Parameters:
-
T
- seeObjIntConsumer
- Parameters:
-
consumer
- theThrowingObjIntConsumer
to be converted, usually a lambda - Returns:
-
converted
ObjIntConsumer
free 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
consumer
throws 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. Nullconsumer
is silently wrapped and causesNullPointerException
when executed.Typical usage:
methodTakingObjLongConsumer(Exceptions.sneak().fromObjLongConsumer((t, v) -> my_throwing_lambda))
- Type Parameters:
-
T
- seeObjLongConsumer
- Parameters:
-
consumer
- theThrowingObjLongConsumer
to be converted, usually a lambda - Returns:
-
converted
ObjLongConsumer
free 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
consumer
throws 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. Nullconsumer
is silently wrapped and causesNullPointerException
when executed.Typical usage:
methodTakingObjDoubleConsumer(Exceptions.sneak().fromObjDoubleConsumer((t, v) -> my_throwing_lambda))
- Type Parameters:
-
T
- seeObjDoubleConsumer
- Parameters:
-
consumer
- theThrowingObjDoubleConsumer
to be converted, usually a lambda - Returns:
-
converted
ObjDoubleConsumer
free 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
predicate
throws 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. Nullpredicate
is silently wrapped and causesNullPointerException
when executed.Typical usage:
methodTakingPredicate(Exceptions.sneak().predicate(t -> my_throwing_lambda))
- Type Parameters:
-
T
- seePredicate
- Parameters:
-
predicate
- theThrowingPredicate
to be converted, usually a lambda - Returns:
-
converted
Predicate
free of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromIntPredicate
public final IntPredicate fromIntPredicate(ThrowingIntPredicate predicate)
Removes checked exceptions from method signature ofThrowingIntPredicate
.If
predicate
throws 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. Nullpredicate
is silently wrapped and causesNullPointerException
when executed.Typical usage:
methodTakingIntPredicate(Exceptions.sneak().fromIntPredicate(v -> my_throwing_lambda))
- Parameters:
-
predicate
- theThrowingIntPredicate
to be converted, usually a lambda - Returns:
-
converted
IntPredicate
free of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromLongPredicate
public final LongPredicate fromLongPredicate(ThrowingLongPredicate predicate)
Removes checked exceptions from method signature ofThrowingLongPredicate
.If
predicate
throws 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. Nullpredicate
is silently wrapped and causesNullPointerException
when executed.Typical usage:
methodTakingLongPredicate(Exceptions.sneak().fromLongPredicate(v -> my_throwing_lambda))
- Parameters:
-
predicate
- theThrowingLongPredicate
to be converted, usually a lambda - Returns:
-
converted
LongPredicate
free of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromDoublePredicate
public final DoublePredicate fromDoublePredicate(ThrowingDoublePredicate predicate)
Removes checked exceptions from method signature ofThrowingDoublePredicate
.If
predicate
throws 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. Nullpredicate
is silently wrapped and causesNullPointerException
when executed.Typical usage:
methodTakingDoublePredicate(Exceptions.sneak().fromDoublePredicate(v -> my_throwing_lambda))
- Parameters:
-
predicate
- theThrowingDoublePredicate
to be converted, usually a lambda - Returns:
-
converted
DoublePredicate
free 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
predicate
throws 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. Nullpredicate
is silently wrapped and causesNullPointerException
when executed.Typical usage:
methodTakingBiPredicate(Exceptions.sneak().fromBiPredicate((t, u) -> my_throwing_lambda))
- Type Parameters:
-
T
- seeBiPredicate
-
U
- seeBiPredicate
- Parameters:
-
predicate
- theThrowingBiPredicate
to be converted, usually a lambda - Returns:
-
converted
BiPredicate
free 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
function
throws 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. Nullfunction
is silently wrapped and causesNullPointerException
when executed.Typical usage:
methodTakingFunction(Exceptions.sneak().function(t -> my_throwing_lambda))
- Type Parameters:
-
T
- seeFunction
-
R
- seeFunction
- Parameters:
-
function
- theThrowingFunction
to be converted, usually a lambda - Returns:
-
converted
Function
free 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
function
throws 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. Nullfunction
is silently wrapped and causesNullPointerException
when executed.Typical usage:
methodTakingToIntFunction(Exceptions.sneak().fromToIntFunction(v -> my_throwing_lambda))
- Type Parameters:
-
T
- seeToIntFunction
- Parameters:
-
function
- theThrowingToIntFunction
to be converted, usually a lambda - Returns:
-
converted
ToIntFunction
free 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
function
throws 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. Nullfunction
is silently wrapped and causesNullPointerException
when executed.Typical usage:
methodTakingIntFunction(Exceptions.sneak().fromIntFunction(v -> my_throwing_lambda))
- Type Parameters:
-
R
- seeIntFunction
- Parameters:
-
function
- theThrowingIntFunction
to be converted, usually a lambda - Returns:
-
converted
IntFunction
free of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromIntToLongFunction
public final IntToLongFunction fromIntToLongFunction(ThrowingIntToLongFunction function)
Removes checked exceptions from method signature ofThrowingIntToLongFunction
.If
function
throws 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. Nullfunction
is silently wrapped and causesNullPointerException
when executed.Typical usage:
methodTakingIntToLongFunction(Exceptions.sneak().fromIntToLongFunction(v -> my_throwing_lambda))
- Parameters:
-
function
- theThrowingIntToLongFunction
to be converted, usually a lambda - Returns:
-
converted
IntToLongFunction
free of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromIntToDoubleFunction
public final IntToDoubleFunction fromIntToDoubleFunction(ThrowingIntToDoubleFunction function)
Removes checked exceptions from method signature ofThrowingIntToDoubleFunction
.If
function
throws 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. Nullfunction
is silently wrapped and causesNullPointerException
when executed.Typical usage:
methodTakingIntToDoubleFunction(Exceptions.sneak().fromIntToDoubleFunction(v -> my_throwing_lambda))
- Parameters:
-
function
- theThrowingIntToDoubleFunction
to be converted, usually a lambda - Returns:
-
converted
IntToDoubleFunction
free 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
function
throws 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. Nullfunction
is silently wrapped and causesNullPointerException
when executed.Typical usage:
methodTakingToLongFunction(Exceptions.sneak().fromToLongFunction(v -> my_throwing_lambda))
- Type Parameters:
-
T
- seeToLongFunction
- Parameters:
-
function
- theThrowingToLongFunction
to be converted, usually a lambda - Returns:
-
converted
ToLongFunction
free 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
function
throws 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. Nullfunction
is silently wrapped and causesNullPointerException
when executed.Typical usage:
methodTakingLongFunction(Exceptions.sneak().fromLongFunction(v -> my_throwing_lambda))
- Type Parameters:
-
R
- seeLongFunction
- Parameters:
-
function
- theThrowingLongFunction
to be converted, usually a lambda - Returns:
-
converted
LongFunction
free of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromLongToIntFunction
public final LongToIntFunction fromLongToIntFunction(ThrowingLongToIntFunction function)
Removes checked exceptions from method signature ofThrowingLongToIntFunction
.If
function
throws 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. Nullfunction
is silently wrapped and causesNullPointerException
when executed.Typical usage:
methodTakingLongToIntFunction(Exceptions.sneak().fromLongToIntFunction(v -> my_throwing_lambda))
- Parameters:
-
function
- theThrowingLongToIntFunction
to be converted, usually a lambda - Returns:
-
converted
LongToIntFunction
free of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromLongToDoubleFunction
public final LongToDoubleFunction fromLongToDoubleFunction(ThrowingLongToDoubleFunction function)
Removes checked exceptions from method signature ofThrowingLongToDoubleFunction
.If
function
throws 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. Nullfunction
is silently wrapped and causesNullPointerException
when executed.Typical usage:
methodTakingLongToDoubleFunction(Exceptions.sneak().fromLongToDoubleFunction(v -> my_throwing_lambda))
- Parameters:
-
function
- theThrowingLongToDoubleFunction
to be converted, usually a lambda - Returns:
-
converted
LongToDoubleFunction
free 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
function
throws 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. Nullfunction
is silently wrapped and causesNullPointerException
when executed.Typical usage:
methodTakingToDoubleFunction(Exceptions.sneak().fromToDoubleFunction(v -> my_throwing_lambda))
- Type Parameters:
-
T
- seeToDoubleFunction
- Parameters:
-
function
- theThrowingToDoubleFunction
to be converted, usually a lambda - Returns:
-
converted
ToDoubleFunction
free 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
function
throws 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. Nullfunction
is silently wrapped and causesNullPointerException
when executed.Typical usage:
methodTakingDoubleFunction(Exceptions.sneak().fromDoubleFunction(v -> my_throwing_lambda))
- Type Parameters:
-
R
- seeDoubleFunction
- Parameters:
-
function
- theThrowingDoubleFunction
to be converted, usually a lambda - Returns:
-
converted
DoubleFunction
free of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromDoubleToIntFunction
public final DoubleToIntFunction fromDoubleToIntFunction(ThrowingDoubleToIntFunction function)
Removes checked exceptions from method signature ofThrowingDoubleToIntFunction
.If
function
throws 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. Nullfunction
is silently wrapped and causesNullPointerException
when executed.Typical usage:
methodTakingDoubleToIntFunction(Exceptions.sneak().fromDoubleToIntFunction(v -> my_throwing_lambda))
- Parameters:
-
function
- theThrowingDoubleToIntFunction
to be converted, usually a lambda - Returns:
-
converted
DoubleToIntFunction
free of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromDoubleToLongFunction
public final DoubleToLongFunction fromDoubleToLongFunction(ThrowingDoubleToLongFunction function)
Removes checked exceptions from method signature ofThrowingDoubleToLongFunction
.If
function
throws 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. Nullfunction
is silently wrapped and causesNullPointerException
when executed.Typical usage:
methodTakingDoubleToLongFunction(Exceptions.sneak().fromDoubleToLongFunction(v -> my_throwing_lambda))
- Parameters:
-
function
- theThrowingDoubleToLongFunction
to be converted, usually a lambda - Returns:
-
converted
DoubleToLongFunction
free 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
operator
throws 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. Nulloperator
is silently wrapped and causesNullPointerException
when executed.Typical usage:
methodTakingUnaryOperator(Exceptions.sneak().fromUnaryOperator(o -> my_throwing_lambda))
- Type Parameters:
-
T
- seeUnaryOperator
- Parameters:
-
operator
- theThrowingUnaryOperator
to be converted, usually a lambda - Returns:
-
converted
UnaryOperator
free of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromIntUnaryOperator
public final IntUnaryOperator fromIntUnaryOperator(ThrowingIntUnaryOperator operator)
Removes checked exceptions from method signature ofThrowingIntUnaryOperator
.If
operator
throws 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. Nulloperator
is silently wrapped and causesNullPointerException
when executed.Typical usage:
methodTakingIntUnaryOperator(Exceptions.sneak().fromIntUnaryOperator(o -> my_throwing_lambda))
- Parameters:
-
operator
- theThrowingIntUnaryOperator
to be converted, usually a lambda - Returns:
-
converted
IntUnaryOperator
free of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromLongUnaryOperator
public final LongUnaryOperator fromLongUnaryOperator(ThrowingLongUnaryOperator operator)
Removes checked exceptions from method signature ofThrowingLongUnaryOperator
.If
operator
throws 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. Nulloperator
is silently wrapped and causesNullPointerException
when executed.Typical usage:
methodTakingLongUnaryOperator(Exceptions.sneak().fromLongUnaryOperator(o -> my_throwing_lambda))
- Parameters:
-
operator
- theThrowingLongUnaryOperator
to be converted, usually a lambda - Returns:
-
converted
LongUnaryOperator
free of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromDoubleUnaryOperator
public final DoubleUnaryOperator fromDoubleUnaryOperator(ThrowingDoubleUnaryOperator operator)
Removes checked exceptions from method signature ofThrowingDoubleUnaryOperator
.If
operator
throws 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. Nulloperator
is silently wrapped and causesNullPointerException
when executed.Typical usage:
methodTakingDoubleUnaryOperator(Exceptions.sneak().fromDoubleUnaryOperator(o -> my_throwing_lambda))
- Parameters:
-
operator
- theThrowingDoubleUnaryOperator
to be converted, usually a lambda - Returns:
-
converted
DoubleUnaryOperator
free 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
function
throws 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. Nullfunction
is silently wrapped and causesNullPointerException
when executed.Typical usage:
methodTakingBiFunction(Exceptions.sneak().fromBiFunction((t, u) -> my_throwing_lambda))
- Type Parameters:
-
T
- seeBiFunction
-
U
- seeBiFunction
-
R
- seeBiFunction
- Parameters:
-
function
- theThrowingBiFunction
to be converted, usually a lambda - Returns:
-
converted
BiFunction
free 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
function
throws 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. Nullfunction
is silently wrapped and causesNullPointerException
when executed.Typical usage:
methodTakingToIntBiFunction(Exceptions.sneak().fromToIntBiFunction((t, u) -> my_throwing_lambda))
- Type Parameters:
-
T
- seeToIntBiFunction
-
U
- seeToIntBiFunction
- Parameters:
-
function
- theThrowingToIntBiFunction
to be converted, usually a lambda - Returns:
-
converted
ToIntBiFunction
free 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
function
throws 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. Nullfunction
is silently wrapped and causesNullPointerException
when executed.Typical usage:
methodTakingToLongBiFunction(Exceptions.sneak().fromToLongBiFunction((t, u) -> my_throwing_lambda))
- Type Parameters:
-
T
- seeToLongBiFunction
-
U
- seeToLongBiFunction
- Parameters:
-
function
- theThrowingToLongBiFunction
to be converted, usually a lambda - Returns:
-
converted
ToLongBiFunction
free 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
function
throws 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. Nullfunction
is silently wrapped and causesNullPointerException
when executed.Typical usage:
methodTakingToDoubleBiFunction(Exceptions.sneak().fromToDoubleBiFunction((t, u) -> my_throwing_lambda))
- Type Parameters:
-
T
- seeToDoubleBiFunction
-
U
- seeToDoubleBiFunction
- Parameters:
-
function
- theThrowingToDoubleBiFunction
to be converted, usually a lambda - Returns:
-
converted
ToDoubleBiFunction
free 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
operator
throws 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. Nulloperator
is silently wrapped and causesNullPointerException
when executed.Typical usage:
methodTakingBinaryOperator(Exceptions.sneak().fromBinaryOperator((l, r) -> my_throwing_lambda))
- Type Parameters:
-
T
- seeBinaryOperator
- Parameters:
-
operator
- theThrowingBinaryOperator
to be converted, usually a lambda - Returns:
-
converted
BinaryOperator
free of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromIntBinaryOperator
public final IntBinaryOperator fromIntBinaryOperator(ThrowingIntBinaryOperator operator)
Removes checked exceptions from method signature ofThrowingIntBinaryOperator
.If
operator
throws 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. Nulloperator
is silently wrapped and causesNullPointerException
when executed.Typical usage:
methodTakingIntBinaryOperator(Exceptions.sneak().fromIntBinaryOperator((l, r) -> my_throwing_lambda))
- Parameters:
-
operator
- theThrowingIntBinaryOperator
to be converted, usually a lambda - Returns:
-
converted
IntBinaryOperator
free of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromLongBinaryOperator
public final LongBinaryOperator fromLongBinaryOperator(ThrowingLongBinaryOperator operator)
Removes checked exceptions from method signature ofThrowingLongBinaryOperator
.If
operator
throws 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. Nulloperator
is silently wrapped and causesNullPointerException
when executed.Typical usage:
methodTakingLongBinaryOperator(Exceptions.sneak().fromLongBinaryOperator((l, r) -> my_throwing_lambda))
- Parameters:
-
operator
- theThrowingLongBinaryOperator
to be converted, usually a lambda - Returns:
-
converted
LongBinaryOperator
free of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
fromDoubleBinaryOperator
public final DoubleBinaryOperator fromDoubleBinaryOperator(ThrowingDoubleBinaryOperator operator)
Removes checked exceptions from method signature ofThrowingDoubleBinaryOperator
.If
operator
throws 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. Nulloperator
is silently wrapped and causesNullPointerException
when executed.Typical usage:
methodTakingDoubleBinaryOperator(Exceptions.sneak().fromDoubleBinaryOperator((l, r) -> my_throwing_lambda))
- Parameters:
-
operator
- theThrowingDoubleBinaryOperator
to be converted, usually a lambda - Returns:
-
converted
DoubleBinaryOperator
free 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
comparator
throws 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. Nullcomparator
is silently wrapped and causesNullPointerException
when executed.Typical usage:
methodTakingComparator(Exceptions.sneak().comparator((l, r) -> my_throwing_lambda))
- Type Parameters:
-
T
- seeComparator
- Parameters:
-
comparator
- theThrowingComparator
to be converted, usually a lambda - Returns:
-
converted
Comparator
free of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
closeable
public final CloseableScope closeable(AutoCloseable closeable)
Removes checked exceptions from method signature ofAutoCloseable
.If
closeable
throws 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. Nullcloseable
is silently wrapped and causesNullPointerException
when executed.Typical usage:
try (var scope = Exceptions.sneak().closeable(openSomething()))
- Parameters:
-
closeable
- theAutoCloseable
to be converted - Returns:
-
converted
CloseableScope
free of checked exceptions - See Also:
-
Tutorial,
Exceptions
-
run
public final void run(ThrowingRunnable runnable)
Filters out checked exceptions while runningThrowingRunnable
.If
runnable
throws 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
- theThrowingRunnable
to run, usually a lambda - Throws:
-
NullPointerException
- ifrunnable
isnull
- See Also:
-
Tutorial,
Exceptions
-
get
public final <T> T get(ThrowingSupplier<T> supplier)
Filters out checked exceptions while runningThrowingSupplier
.If
supplier
throws 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
- theThrowingSupplier
to run, usually a lambda - Returns:
-
value returned from
supplier
- Throws:
-
NullPointerException
- ifsupplier
isnull
- See Also:
-
Tutorial,
Exceptions
-
getAsInt
public final int getAsInt(ThrowingIntSupplier supplier)
Filters out checked exceptions while runningThrowingIntSupplier
.If
supplier
throws 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
- theThrowingIntSupplier
to run, usually a lambda - Returns:
-
value returned from
supplier
- Throws:
-
NullPointerException
- ifsupplier
isnull
- See Also:
-
Tutorial,
Exceptions
-
getAsLong
public final long getAsLong(ThrowingLongSupplier supplier)
Filters out checked exceptions while runningThrowingLongSupplier
.If
supplier
throws 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
- theThrowingLongSupplier
to run, usually a lambda - Returns:
-
value returned from
supplier
- Throws:
-
NullPointerException
- ifsupplier
isnull
- See Also:
-
Tutorial,
Exceptions
-
getAsDouble
public final double getAsDouble(ThrowingDoubleSupplier supplier)
Filters out checked exceptions while runningThrowingDoubleSupplier
.If
supplier
throws 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
- theThrowingDoubleSupplier
to run, usually a lambda - Returns:
-
value returned from
supplier
- Throws:
-
NullPointerException
- ifsupplier
isnull
- See Also:
-
Tutorial,
Exceptions
-
getAsBoolean
public final boolean getAsBoolean(ThrowingBooleanSupplier supplier)
Filters out checked exceptions while runningThrowingBooleanSupplier
.If
supplier
throws 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
- theThrowingBooleanSupplier
to run, usually a lambda - Returns:
-
value returned from
supplier
- Throws:
-
NullPointerException
- ifsupplier
isnull
- See Also:
-
Tutorial,
Exceptions
-
-