public abstract class ExceptionFilter extends Object
handle(Throwable)
defines the exception handling policy when implemented in derived class. See noexception tutorial.
Typical usage: Exceptions.log().passing().get(() -> my_throwing_lambda)
All wrapping methods surround the functional interface with a try-catch block. If the functional interface throws, the exception is caught and passed to handle(Throwable)
. NullPointerException
from null
functional interface is caught too. Method handle(Throwable)
applies exception handling policy (log, count, ignore, etc.) and throws a replacement or wrapping exception. If it returns without throwing any exception, the original exception is rethrown.
Wrapping methods for all standard functional interfaces are provided. Simple interfaces have short method names like runnable(Runnable)
or supplier(Supplier)
. Interfaces with longer names have methods that follow fromX
naming pattern, for example fromUnaryOperator(UnaryOperator)
. Parameterless functional interfaces can be called directly by methods run(Runnable)
, get(Supplier)
, and the various getAsX
variants.
Modifier | Constructor and Description |
---|---|
protected |
ExceptionFilter()
Initializes new ExceptionFilter .
|
public abstract void handle(Throwable exception)
ExceptionHandler.passing()
. All other methods of the ExceptionFilter
call this method, but it can be also called directly.
This method represents reusable catch block that handles all exceptions in the same way. When invoked, it must somehow handle the provided exception, for example by logging it. It can also replace or wrap the exception by throwing a new exception. If this method returns without throwing, it is a signal that the original exception should be rethrown. All other methods of this class will rethrow in that case.
exception
- the exception to handle
NullPointerException
- if exception
is null
Exceptions
public final Runnable runnable(Runnable runnable)
Runnable
.
If runnable
throws an exception, the exception is caught and passed to handle(Throwable)
. NullPointerException
from null
runnable
is caught too. Method handle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.
Typical usage: methodTakingRunnable(Exceptions.log().passing().runnable(() -> my_throwing_lambda))
runnable
- the Runnable
to wrap, usually a lambda
Runnable
in a try-catch block
Exceptions
public final <T> Supplier<T> supplier(Supplier<T> supplier)
Supplier
.
If supplier
throws an exception, the exception is caught and passed to handle(Throwable)
. NullPointerException
from null
supplier
is caught too. Method handle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.
Typical usage: methodTakingSupplier(Exceptions.log().passing().supplier(() -> my_throwing_lambda))
T
- see Supplier
supplier
- the Supplier
to wrap, usually a lambda
Supplier
in a try-catch block
Exceptions
public final IntSupplier fromIntSupplier(IntSupplier supplier)
IntSupplier
.
If supplier
throws an exception, the exception is caught and passed to handle(Throwable)
. NullPointerException
from null
supplier
is caught too. Method handle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.
Typical usage: methodTakingIntSupplier(Exceptions.log().passing().fromIntSupplier(() -> my_throwing_lambda))
supplier
- the IntSupplier
to wrap, usually a lambda
IntSupplier
in a try-catch block
Exceptions
public final LongSupplier fromLongSupplier(LongSupplier supplier)
LongSupplier
.
If supplier
throws an exception, the exception is caught and passed to handle(Throwable)
. NullPointerException
from null
supplier
is caught too. Method handle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.
Typical usage: methodTakingLongSupplier(Exceptions.log().passing().fromLongSupplier(() -> my_throwing_lambda))
supplier
- the LongSupplier
to wrap, usually a lambda
LongSupplier
in a try-catch block
Exceptions
public final DoubleSupplier fromDoubleSupplier(DoubleSupplier supplier)
DoubleSupplier
.
If supplier
throws an exception, the exception is caught and passed to handle(Throwable)
. NullPointerException
from null
supplier
is caught too. Method handle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.
Typical usage: methodTakingDoubleSupplier(Exceptions.log().passing().fromDoubleSupplier(() -> my_throwing_lambda))
supplier
- the DoubleSupplier
to wrap, usually a lambda
DoubleSupplier
in a try-catch block
Exceptions
public final BooleanSupplier fromBooleanSupplier(BooleanSupplier supplier)
BooleanSupplier
.
If supplier
throws an exception, the exception is caught and passed to handle(Throwable)
. NullPointerException
from null
supplier
is caught too. Method handle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.
Typical usage: methodTakingBooleanSupplier(Exceptions.log().passing().fromBooleanSupplier(() -> my_throwing_lambda))
supplier
- the BooleanSupplier
to wrap, usually a lambda
BooleanSupplier
in a try-catch block
Exceptions
public final <T> Consumer<T> consumer(Consumer<T> consumer)
Consumer
.
If consumer
throws an exception, the exception is caught and passed to handle(Throwable)
. NullPointerException
from null
consumer
is caught too. Method handle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.
Typical usage: methodTakingConsumer(Exceptions.log().passing().consumer(t -> my_throwing_lambda))
T
- see Consumer
consumer
- the Consumer
to wrap, usually a lambda
Consumer
in a try-catch block
Exceptions
public final IntConsumer fromIntConsumer(IntConsumer consumer)
IntConsumer
.
If consumer
throws an exception, the exception is caught and passed to handle(Throwable)
. NullPointerException
from null
consumer
is caught too. Method handle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.
Typical usage: methodTakingIntConsumer(Exceptions.log().passing().fromIntConsumer(v -> my_throwing_lambda))
consumer
- the IntConsumer
to wrap, usually a lambda
IntConsumer
in a try-catch block
Exceptions
public final LongConsumer fromLongConsumer(LongConsumer consumer)
LongConsumer
.
If consumer
throws an exception, the exception is caught and passed to handle(Throwable)
. NullPointerException
from null
consumer
is caught too. Method handle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.
Typical usage: methodTakingLongConsumer(Exceptions.log().passing().fromLongConsumer(v -> my_throwing_lambda))
consumer
- the LongConsumer
to wrap, usually a lambda
LongConsumer
in a try-catch block
Exceptions
public final DoubleConsumer fromDoubleConsumer(DoubleConsumer consumer)
DoubleConsumer
.
If consumer
throws an exception, the exception is caught and passed to handle(Throwable)
. NullPointerException
from null
consumer
is caught too. Method handle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.
Typical usage: methodTakingDoubleConsumer(Exceptions.log().passing().fromDoubleConsumer(v -> my_throwing_lambda))
consumer
- the DoubleConsumer
to wrap, usually a lambda
DoubleConsumer
in a try-catch block
Exceptions
public final <T,U> BiConsumer<T,U> fromBiConsumer(BiConsumer<T,U> consumer)
BiConsumer
.
If consumer
throws an exception, the exception is caught and passed to handle(Throwable)
. NullPointerException
from null
consumer
is caught too. Method handle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.
Typical usage: methodTakingBiConsumer(Exceptions.log().passing().fromBiConsumer((t, u) -> my_throwing_lambda))
T
- see BiConsumer
U
- see BiConsumer
consumer
- the BiConsumer
to wrap, usually a lambda
BiConsumer
in a try-catch block
Exceptions
public final <T> ObjIntConsumer<T> fromObjIntConsumer(ObjIntConsumer<T> consumer)
ObjIntConsumer
.
If consumer
throws an exception, the exception is caught and passed to handle(Throwable)
. NullPointerException
from null
consumer
is caught too. Method handle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.
Typical usage: methodTakingObjIntConsumer(Exceptions.log().passing().fromObjIntConsumer((t, v) -> my_throwing_lambda))
T
- see ObjIntConsumer
consumer
- the ObjIntConsumer
to wrap, usually a lambda
ObjIntConsumer
in a try-catch block
Exceptions
public final <T> ObjLongConsumer<T> fromObjLongConsumer(ObjLongConsumer<T> consumer)
ObjLongConsumer
.
If consumer
throws an exception, the exception is caught and passed to handle(Throwable)
. NullPointerException
from null
consumer
is caught too. Method handle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.
Typical usage: methodTakingObjLongConsumer(Exceptions.log().passing().fromObjLongConsumer((t, v) -> my_throwing_lambda))
T
- see ObjLongConsumer
consumer
- the ObjLongConsumer
to wrap, usually a lambda
ObjLongConsumer
in a try-catch block
Exceptions
public final <T> ObjDoubleConsumer<T> fromObjDoubleConsumer(ObjDoubleConsumer<T> consumer)
ObjDoubleConsumer
.
If consumer
throws an exception, the exception is caught and passed to handle(Throwable)
. NullPointerException
from null
consumer
is caught too. Method handle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.
Typical usage: methodTakingObjDoubleConsumer(Exceptions.log().passing().fromObjDoubleConsumer((t, v) -> my_throwing_lambda))
T
- see ObjDoubleConsumer
consumer
- the ObjDoubleConsumer
to wrap, usually a lambda
ObjDoubleConsumer
in a try-catch block
Exceptions
public final <T> Predicate<T> predicate(Predicate<T> predicate)
Predicate
.
If predicate
throws an exception, the exception is caught and passed to handle(Throwable)
. NullPointerException
from null
predicate
is caught too. Method handle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.
Typical usage: methodTakingPredicate(Exceptions.log().passing().predicate(t -> my_throwing_lambda))
T
- see Predicate
predicate
- the Predicate
to wrap, usually a lambda
Predicate
in a try-catch block
Exceptions
public final IntPredicate fromIntPredicate(IntPredicate predicate)
IntPredicate
.
If predicate
throws an exception, the exception is caught and passed to handle(Throwable)
. NullPointerException
from null
predicate
is caught too. Method handle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.
Typical usage: methodTakingIntPredicate(Exceptions.log().passing().fromIntPredicate(v -> my_throwing_lambda))
predicate
- the IntPredicate
to wrap, usually a lambda
IntPredicate
in a try-catch block
Exceptions
public final LongPredicate fromLongPredicate(LongPredicate predicate)
LongPredicate
.
If predicate
throws an exception, the exception is caught and passed to handle(Throwable)
. NullPointerException
from null
predicate
is caught too. Method handle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.
Typical usage: methodTakingLongPredicate(Exceptions.log().passing().fromLongPredicate(v -> my_throwing_lambda))
predicate
- the LongPredicate
to wrap, usually a lambda
LongPredicate
in a try-catch block
Exceptions
public final DoublePredicate fromDoublePredicate(DoublePredicate predicate)
DoublePredicate
.
If predicate
throws an exception, the exception is caught and passed to handle(Throwable)
. NullPointerException
from null
predicate
is caught too. Method handle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.
Typical usage: methodTakingDoublePredicate(Exceptions.log().passing().fromDoublePredicate(v -> my_throwing_lambda))
predicate
- the DoublePredicate
to wrap, usually a lambda
DoublePredicate
in a try-catch block
Exceptions
public final <T,U> BiPredicate<T,U> fromBiPredicate(BiPredicate<T,U> predicate)
BiPredicate
.
If predicate
throws an exception, the exception is caught and passed to handle(Throwable)
. NullPointerException
from null
predicate
is caught too. Method handle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.
Typical usage: methodTakingBiPredicate(Exceptions.log().passing().fromBiPredicate((t, u) -> my_throwing_lambda))
T
- see BiPredicate
U
- see BiPredicate
predicate
- the BiPredicate
to wrap, usually a lambda
BiPredicate
in a try-catch block
Exceptions
public final <T,R> Function<T,R> function(Function<T,R> function)
Function
.
If function
throws an exception, the exception is caught and passed to handle(Throwable)
. NullPointerException
from null
function
is caught too. Method handle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.
Typical usage: methodTakingFunction(Exceptions.log().passing().function(t -> my_throwing_lambda))
public final <T> ToIntFunction<T> fromToIntFunction(ToIntFunction<T> function)
ToIntFunction
.
If function
throws an exception, the exception is caught and passed to handle(Throwable)
. NullPointerException
from null
function
is caught too. Method handle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.
Typical usage: methodTakingToIntFunction(Exceptions.log().passing().fromToIntFunction(v -> my_throwing_lambda))
T
- see ToIntFunction
function
- the ToIntFunction
to wrap, usually a lambda
ToIntFunction
in a try-catch block
Exceptions
public final <R> IntFunction<R> fromIntFunction(IntFunction<R> function)
IntFunction
.
If function
throws an exception, the exception is caught and passed to handle(Throwable)
. NullPointerException
from null
function
is caught too. Method handle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.
Typical usage: methodTakingIntFunction(Exceptions.log().passing().fromIntFunction(v -> my_throwing_lambda))
R
- see IntFunction
function
- the IntFunction
to wrap, usually a lambda
IntFunction
in a try-catch block
Exceptions
public final IntToLongFunction fromIntToLongFunction(IntToLongFunction function)
IntToLongFunction
.
If function
throws an exception, the exception is caught and passed to handle(Throwable)
. NullPointerException
from null
function
is caught too. Method handle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.
Typical usage: methodTakingIntToLongFunction(Exceptions.log().passing().fromIntToLongFunction(v -> my_throwing_lambda))
function
- the IntToLongFunction
to wrap, usually a lambda
IntToLongFunction
in a try-catch block
Exceptions
public final IntToDoubleFunction fromIntToDoubleFunction(IntToDoubleFunction function)
IntToDoubleFunction
.
If function
throws an exception, the exception is caught and passed to handle(Throwable)
. NullPointerException
from null
function
is caught too. Method handle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.
Typical usage: methodTakingIntToDoubleFunction(Exceptions.log().passing().fromIntToDoubleFunction(v -> my_throwing_lambda))
function
- the IntToDoubleFunction
to wrap, usually a lambda
IntToDoubleFunction
in a try-catch block
Exceptions
public final <T> ToLongFunction<T> fromToLongFunction(ToLongFunction<T> function)
ToLongFunction
.
If function
throws an exception, the exception is caught and passed to handle(Throwable)
. NullPointerException
from null
function
is caught too. Method handle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.
Typical usage: methodTakingToLongFunction(Exceptions.log().passing().fromToLongFunction(v -> my_throwing_lambda))
T
- see ToLongFunction
function
- the ToLongFunction
to wrap, usually a lambda
ToLongFunction
in a try-catch block
Exceptions
public final <R> LongFunction<R> fromLongFunction(LongFunction<R> function)
LongFunction
.
If function
throws an exception, the exception is caught and passed to handle(Throwable)
. NullPointerException
from null
function
is caught too. Method handle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.
Typical usage: methodTakingLongFunction(Exceptions.log().passing().fromLongFunction(v -> my_throwing_lambda))
R
- see LongFunction
function
- the LongFunction
to wrap, usually a lambda
LongFunction
in a try-catch block
Exceptions
public final LongToIntFunction fromLongToIntFunction(LongToIntFunction function)
LongToIntFunction
.
If function
throws an exception, the exception is caught and passed to handle(Throwable)
. NullPointerException
from null
function
is caught too. Method handle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.
Typical usage: methodTakingLongToIntFunction(Exceptions.log().passing().fromLongToIntFunction(v -> my_throwing_lambda))
function
- the LongToIntFunction
to wrap, usually a lambda
LongToIntFunction
in a try-catch block
Exceptions
public final LongToDoubleFunction fromLongToDoubleFunction(LongToDoubleFunction function)
LongToDoubleFunction
.
If function
throws an exception, the exception is caught and passed to handle(Throwable)
. NullPointerException
from null
function
is caught too. Method handle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.
Typical usage: methodTakingLongToDoubleFunction(Exceptions.log().passing().fromLongToDoubleFunction(v -> my_throwing_lambda))
function
- the LongToDoubleFunction
to wrap, usually a lambda
LongToDoubleFunction
in a try-catch block
Exceptions
public final <T> ToDoubleFunction<T> fromToDoubleFunction(ToDoubleFunction<T> function)
ToDoubleFunction
.
If function
throws an exception, the exception is caught and passed to handle(Throwable)
. NullPointerException
from null
function
is caught too. Method handle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.
Typical usage: methodTakingToDoubleFunction(Exceptions.log().passing().fromToDoubleFunction(v -> my_throwing_lambda))
T
- see ToDoubleFunction
function
- the ToDoubleFunction
to wrap, usually a lambda
ToDoubleFunction
in a try-catch block
Exceptions
public final <R> DoubleFunction<R> fromDoubleFunction(DoubleFunction<R> function)
DoubleFunction
.
If function
throws an exception, the exception is caught and passed to handle(Throwable)
. NullPointerException
from null
function
is caught too. Method handle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.
Typical usage: methodTakingDoubleFunction(Exceptions.log().passing().fromDoubleFunction(v -> my_throwing_lambda))
R
- see DoubleFunction
function
- the DoubleFunction
to wrap, usually a lambda
DoubleFunction
in a try-catch block
Exceptions
public final DoubleToIntFunction fromDoubleToIntFunction(DoubleToIntFunction function)
DoubleToIntFunction
.
If function
throws an exception, the exception is caught and passed to handle(Throwable)
. NullPointerException
from null
function
is caught too. Method handle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.
Typical usage: methodTakingDoubleToIntFunction(Exceptions.log().passing().fromDoubleToIntFunction(v -> my_throwing_lambda))
function
- the DoubleToIntFunction
to wrap, usually a lambda
DoubleToIntFunction
in a try-catch block
Exceptions
public final DoubleToLongFunction fromDoubleToLongFunction(DoubleToLongFunction function)
DoubleToLongFunction
.
If function
throws an exception, the exception is caught and passed to handle(Throwable)
. NullPointerException
from null
function
is caught too. Method handle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.
Typical usage: methodTakingDoubleToLongFunction(Exceptions.log().passing().fromDoubleToLongFunction(v -> my_throwing_lambda))
function
- the DoubleToLongFunction
to wrap, usually a lambda
DoubleToLongFunction
in a try-catch block
Exceptions
public final <T> UnaryOperator<T> fromUnaryOperator(UnaryOperator<T> operator)
UnaryOperator
.
If operator
throws an exception, the exception is caught and passed to handle(Throwable)
. NullPointerException
from null
operator
is caught too. Method handle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.
Typical usage: methodTakingUnaryOperator(Exceptions.log().passing().fromUnaryOperator(o -> my_throwing_lambda))
T
- see UnaryOperator
operator
- the UnaryOperator
to wrap, usually a lambda
UnaryOperator
in a try-catch block
Exceptions
public final IntUnaryOperator fromIntUnaryOperator(IntUnaryOperator operator)
IntUnaryOperator
.
If operator
throws an exception, the exception is caught and passed to handle(Throwable)
. NullPointerException
from null
operator
is caught too. Method handle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.
Typical usage: methodTakingIntUnaryOperator(Exceptions.log().passing().fromIntUnaryOperator(o -> my_throwing_lambda))
operator
- the IntUnaryOperator
to wrap, usually a lambda
IntUnaryOperator
in a try-catch block
Exceptions
public final LongUnaryOperator fromLongUnaryOperator(LongUnaryOperator operator)
LongUnaryOperator
.
If operator
throws an exception, the exception is caught and passed to handle(Throwable)
. NullPointerException
from null
operator
is caught too. Method handle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.
Typical usage: methodTakingLongUnaryOperator(Exceptions.log().passing().fromLongUnaryOperator(o -> my_throwing_lambda))
operator
- the LongUnaryOperator
to wrap, usually a lambda
LongUnaryOperator
in a try-catch block
Exceptions
public final DoubleUnaryOperator fromDoubleUnaryOperator(DoubleUnaryOperator operator)
DoubleUnaryOperator
.
If operator
throws an exception, the exception is caught and passed to handle(Throwable)
. NullPointerException
from null
operator
is caught too. Method handle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.
Typical usage: methodTakingDoubleUnaryOperator(Exceptions.log().passing().fromDoubleUnaryOperator(o -> my_throwing_lambda))
operator
- the DoubleUnaryOperator
to wrap, usually a lambda
DoubleUnaryOperator
in a try-catch block
Exceptions
public final <T,U,R> BiFunction<T,U,R> fromBiFunction(BiFunction<T,U,R> function)
BiFunction
.
If function
throws an exception, the exception is caught and passed to handle(Throwable)
. NullPointerException
from null
function
is caught too. Method handle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.
Typical usage: methodTakingBiFunction(Exceptions.log().passing().fromBiFunction((t, u) -> my_throwing_lambda))
T
- see BiFunction
U
- see BiFunction
R
- see BiFunction
function
- the BiFunction
to wrap, usually a lambda
BiFunction
in a try-catch block
Exceptions
public final <T,U> ToIntBiFunction<T,U> fromToIntBiFunction(ToIntBiFunction<T,U> function)
ToIntBiFunction
.
If function
throws an exception, the exception is caught and passed to handle(Throwable)
. NullPointerException
from null
function
is caught too. Method handle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.
Typical usage: methodTakingToIntBiFunction(Exceptions.log().passing().fromToIntBiFunction((t, u) -> my_throwing_lambda))
T
- see ToIntBiFunction
U
- see ToIntBiFunction
function
- the ToIntBiFunction
to wrap, usually a lambda
ToIntBiFunction
in a try-catch block
Exceptions
public final <T,U> ToLongBiFunction<T,U> fromToLongBiFunction(ToLongBiFunction<T,U> function)
ToLongBiFunction
.
If function
throws an exception, the exception is caught and passed to handle(Throwable)
. NullPointerException
from null
function
is caught too. Method handle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.
Typical usage: methodTakingToLongBiFunction(Exceptions.log().passing().fromToLongBiFunction((t, u) -> my_throwing_lambda))
T
- see ToLongBiFunction
U
- see ToLongBiFunction
function
- the ToLongBiFunction
to wrap, usually a lambda
ToLongBiFunction
in a try-catch block
Exceptions
public final <T,U> ToDoubleBiFunction<T,U> fromToDoubleBiFunction(ToDoubleBiFunction<T,U> function)
ToDoubleBiFunction
.
If function
throws an exception, the exception is caught and passed to handle(Throwable)
. NullPointerException
from null
function
is caught too. Method handle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.
Typical usage: methodTakingToDoubleBiFunction(Exceptions.log().passing().fromToDoubleBiFunction((t, u) -> my_throwing_lambda))
T
- see ToDoubleBiFunction
U
- see ToDoubleBiFunction
function
- the ToDoubleBiFunction
to wrap, usually a lambda
ToDoubleBiFunction
in a try-catch block
Exceptions
public final <T> BinaryOperator<T> fromBinaryOperator(BinaryOperator<T> operator)
BinaryOperator
.
If operator
throws an exception, the exception is caught and passed to handle(Throwable)
. NullPointerException
from null
operator
is caught too. Method handle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.
Typical usage: methodTakingBinaryOperator(Exceptions.log().passing().fromBinaryOperator((l, r) -> my_throwing_lambda))
T
- see BinaryOperator
operator
- the BinaryOperator
to wrap, usually a lambda
BinaryOperator
in a try-catch block
Exceptions
public final IntBinaryOperator fromIntBinaryOperator(IntBinaryOperator operator)
IntBinaryOperator
.
If operator
throws an exception, the exception is caught and passed to handle(Throwable)
. NullPointerException
from null
operator
is caught too. Method handle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.
Typical usage: methodTakingIntBinaryOperator(Exceptions.log().passing().fromIntBinaryOperator((l, r) -> my_throwing_lambda))
operator
- the IntBinaryOperator
to wrap, usually a lambda
IntBinaryOperator
in a try-catch block
Exceptions
public final LongBinaryOperator fromLongBinaryOperator(LongBinaryOperator operator)
LongBinaryOperator
.
If operator
throws an exception, the exception is caught and passed to handle(Throwable)
. NullPointerException
from null
operator
is caught too. Method handle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.
Typical usage: methodTakingLongBinaryOperator(Exceptions.log().passing().fromLongBinaryOperator((l, r) -> my_throwing_lambda))
operator
- the LongBinaryOperator
to wrap, usually a lambda
LongBinaryOperator
in a try-catch block
Exceptions
public final DoubleBinaryOperator fromDoubleBinaryOperator(DoubleBinaryOperator operator)
DoubleBinaryOperator
.
If operator
throws an exception, the exception is caught and passed to handle(Throwable)
. NullPointerException
from null
operator
is caught too. Method handle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.
Typical usage: methodTakingDoubleBinaryOperator(Exceptions.log().passing().fromDoubleBinaryOperator((l, r) -> my_throwing_lambda))
operator
- the DoubleBinaryOperator
to wrap, usually a lambda
DoubleBinaryOperator
in a try-catch block
Exceptions
public final <T> Comparator<T> comparator(Comparator<T> comparator)
Comparator
.
If comparator
throws an exception, the exception is caught and passed to handle(Throwable)
. NullPointerException
from null
comparator
is caught too. Method handle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.
Typical usage: methodTakingComparator(Exceptions.log().passing().comparator((l, r) -> my_throwing_lambda))
T
- see Comparator
comparator
- the Comparator
to wrap, usually a lambda
Comparator
in a try-catch block
Exceptions
public final CloseableScope closeable(CloseableScope closeable)
CloseableScope
.
If closeable
throws an exception, the exception is caught and passed to handle(Throwable)
. NullPointerException
from null
closeable
is caught too. Method handle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.
Typical usage: try (var scope = Exceptions.log().passing().closeable(openSomething()))
closeable
- the CloseableScope
to wrap
CloseableScope
in a try-catch block
Exceptions
public final void run(Runnable runnable)
Runnable
.
If runnable
throws an exception, the exception is caught and passed to handle(Throwable)
. NullPointerException
from null
runnable
is caught too. Method handle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.
Typical usage: Exceptions.log().passing().run(() -> my_throwing_lambda))
runnable
- the Runnable
to run, usually a lambda
NullPointerException
- if runnable
is null
Exceptions
public final <T> T get(Supplier<T> supplier)
Supplier
.
If supplier
throws an exception, the exception is caught and passed to handle(Throwable)
. NullPointerException
from null
supplier
is caught too. Method handle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.
Typical usage: Exceptions.log().passing().get(() -> my_throwing_lambda))
T
- see Supplier
supplier
- the Supplier
to run, usually a lambda
supplier
NullPointerException
- if supplier
is null
Exceptions
public final int getAsInt(IntSupplier supplier)
IntSupplier
.
If supplier
throws an exception, the exception is caught and passed to handle(Throwable)
. NullPointerException
from null
supplier
is caught too. Method handle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.
Typical usage: Exceptions.log().passing().getAsInt(() -> my_throwing_lambda))
supplier
- the IntSupplier
to run, usually a lambda
supplier
NullPointerException
- if supplier
is null
Exceptions
public final long getAsLong(LongSupplier supplier)
LongSupplier
.
If supplier
throws an exception, the exception is caught and passed to handle(Throwable)
. NullPointerException
from null
supplier
is caught too. Method handle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.
Typical usage: Exceptions.log().passing().getAsLong(() -> my_throwing_lambda))
supplier
- the LongSupplier
to run, usually a lambda
supplier
NullPointerException
- if supplier
is null
Exceptions
public final double getAsDouble(DoubleSupplier supplier)
DoubleSupplier
.
If supplier
throws an exception, the exception is caught and passed to handle(Throwable)
. NullPointerException
from null
supplier
is caught too. Method handle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.
Typical usage: Exceptions.log().passing().getAsDouble(() -> my_throwing_lambda))
supplier
- the DoubleSupplier
to run, usually a lambda
supplier
NullPointerException
- if supplier
is null
Exceptions
public final boolean getAsBoolean(BooleanSupplier supplier)
BooleanSupplier
.
If supplier
throws an exception, the exception is caught and passed to handle(Throwable)
. NullPointerException
from null
supplier
is caught too. Method handle(Throwable)
is free to throw any replacement exception. If it returns, the original exception is rethrown.
Typical usage: Exceptions.log().passing().getAsBoolean(() -> my_throwing_lambda))
supplier
- the BooleanSupplier
to run, usually a lambda
supplier
NullPointerException
- if supplier
is null
Exceptions
Copyright © 2017–2020 Robert Važan. All rights reserved.