- java.lang.Object
-
- org.jooq.lambda.Unchecked
-
public final class Unchecked extends java.lang.Object
Improved interoperability between checked exceptions and Java 8.Checked exceptions are one of Java's biggest flaws. Due to backwards-compatibility, we're inheriting all the checked exception trouble back from JDK 1.0. This becomes even more obvious when using lambda expressions, most of which are not allowed to throw checked exceptions.
This library tries to ease some pain and wraps / unwraps a variety of API elements from the JDK 8 to improve interoperability with checked exceptions.
-
-
Field Summary
Fields Modifier and Type Field Description static java.util.function.Consumer<java.lang.Throwable>
RETHROW_ALL
AConsumer
that rethrows all exceptions, including checked exceptions.static java.util.function.Consumer<java.lang.Throwable>
THROWABLE_TO_RUNTIME_EXCEPTION
AConsumer
that wraps anyThrowable
in aRuntimeException
.
-
Constructor Summary
Constructors Modifier Constructor Description private
Unchecked()
No instances
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T,U>
java.util.function.BiConsumer<T,U>biConsumer(CheckedBiConsumer<T,U> consumer)
Wrap aCheckedBiConsumer
in aBiConsumer
.static <T,U>
java.util.function.BiConsumer<T,U>biConsumer(CheckedBiConsumer<T,U> consumer, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedBiConsumer
in aBiConsumer
with a custom handler for checked exceptions.static <T,U,R>
java.util.function.BiFunction<T,U,R>biFunction(CheckedBiFunction<T,U,R> function)
Wrap aCheckedBiFunction
in aBiFunction
.static <T,U,R>
java.util.function.BiFunction<T,U,R>biFunction(CheckedBiFunction<T,U,R> function, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedBiFunction
in aBiFunction
with a custom handler for checked exceptions.static <T> java.util.function.BinaryOperator<T>
binaryOperator(CheckedBinaryOperator<T> operator)
Wrap aCheckedBinaryOperator
in aBinaryOperator
.static <T> java.util.function.BinaryOperator<T>
binaryOperator(CheckedBinaryOperator<T> operator, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedBinaryOperator
in aBinaryOperator
with a custom handler for checked exceptions.static <T,U>
java.util.function.BiPredicate<T,U>biPredicate(CheckedBiPredicate<T,U> predicate)
Wrap aCheckedBiPredicate
in aBiPredicate
.static <T,U>
java.util.function.BiPredicate<T,U>biPredicate(CheckedBiPredicate<T,U> predicate, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedBiPredicate
in aBiPredicate
with a custom handler for checked exceptions.static java.util.function.BooleanSupplier
booleanSupplier(CheckedBooleanSupplier supplier)
Wrap aCheckedBooleanSupplier
in aBooleanSupplier
.static java.util.function.BooleanSupplier
booleanSupplier(CheckedBooleanSupplier supplier, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedBooleanSupplier
in aBooleanSupplier
with a custom handler for checked exceptions.static <T> java.util.concurrent.Callable<T>
callable(CheckedCallable<T> callable)
Wrap aCheckedCallable
in aCallable
.static <T> java.util.concurrent.Callable<T>
callable(CheckedCallable<T> callable, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedCallable
in aCallable
with a custom handler for checked exceptions.static <T> java.util.Comparator<T>
comparator(CheckedComparator<T> comparator)
Wrap aCheckedComparator
in aComparator
.static <T> java.util.Comparator<T>
comparator(CheckedComparator<T> comparator, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedComparator
in aComparator
with a custom handler for checked exceptions.static <T> java.util.function.Consumer<T>
consumer(CheckedConsumer<T> consumer)
Wrap aCheckedConsumer
in aConsumer
.static <T> java.util.function.Consumer<T>
consumer(CheckedConsumer<T> consumer, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedConsumer
in aConsumer
with a custom handler for checked exceptions.static java.util.function.DoubleBinaryOperator
doubleBinaryOperator(CheckedDoubleBinaryOperator operator)
Wrap aCheckedDoubleBinaryOperator
in aDoubleBinaryOperator
.static java.util.function.DoubleBinaryOperator
doubleBinaryOperator(CheckedDoubleBinaryOperator operator, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedDoubleBinaryOperator
in aDoubleBinaryOperator
with a custom handler for checked exceptions.static java.util.function.DoubleConsumer
doubleConsumer(CheckedDoubleConsumer consumer)
Wrap aCheckedDoubleConsumer
in aDoubleConsumer
.static java.util.function.DoubleConsumer
doubleConsumer(CheckedDoubleConsumer consumer, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedDoubleConsumer
in aDoubleConsumer
with a custom handler for checked exceptions.static <R> java.util.function.DoubleFunction<R>
doubleFunction(CheckedDoubleFunction<R> function)
Wrap aCheckedDoubleFunction
in aDoubleFunction
.static <R> java.util.function.DoubleFunction<R>
doubleFunction(CheckedDoubleFunction<R> function, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedDoubleFunction
in aDoubleFunction
with a custom handler for checked exceptions.static java.util.function.DoublePredicate
doublePredicate(CheckedDoublePredicate predicate)
Wrap aCheckedDoublePredicate
in aDoublePredicate
.static java.util.function.DoublePredicate
doublePredicate(CheckedDoublePredicate function, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedDoublePredicate
in aDoublePredicate
with a custom handler for checked exceptions.static java.util.function.DoubleSupplier
doubleSupplier(CheckedDoubleSupplier supplier)
Wrap aCheckedDoubleSupplier
in aDoubleSupplier
.static java.util.function.DoubleSupplier
doubleSupplier(CheckedDoubleSupplier supplier, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedDoubleSupplier
in aDoubleSupplier
with a custom handler for checked exceptions.static java.util.function.DoubleToIntFunction
doubleToIntFunction(CheckedDoubleToIntFunction function)
Wrap aCheckedDoubleToIntFunction
in aDoubleToIntFunction
.static java.util.function.DoubleToIntFunction
doubleToIntFunction(CheckedDoubleToIntFunction function, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedDoubleToIntFunction
in aDoubleToIntFunction
with a custom handler for checked exceptions.static java.util.function.DoubleToLongFunction
doubleToLongFunction(CheckedDoubleToLongFunction function)
Wrap aCheckedDoubleToLongFunction
in aDoubleToLongFunction
.static java.util.function.DoubleToLongFunction
doubleToLongFunction(CheckedDoubleToLongFunction function, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedDoubleToLongFunction
in aDoubleToLongFunction
with a custom handler for checked exceptions.static java.util.function.DoubleUnaryOperator
doubleUnaryOperator(CheckedDoubleUnaryOperator operator)
Wrap aCheckedDoubleUnaryOperator
in aDoubleUnaryOperator
.static java.util.function.DoubleUnaryOperator
doubleUnaryOperator(CheckedDoubleUnaryOperator operator, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedDoubleUnaryOperator
in aDoubleUnaryOperator
with a custom handler for checked exceptions.static <T,R>
java.util.function.Function<T,R>function(CheckedFunction<T,R> function)
Wrap aCheckedFunction
in aFunction
.static <T,R>
java.util.function.Function<T,R>function(CheckedFunction<T,R> function, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedFunction
in aFunction
with a custom handler for checked exceptions.static java.util.function.IntBinaryOperator
intBinaryOperator(CheckedIntBinaryOperator operator)
Wrap aCheckedIntBinaryOperator
in aIntBinaryOperator
.static java.util.function.IntBinaryOperator
intBinaryOperator(CheckedIntBinaryOperator operator, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedIntBinaryOperator
in aIntBinaryOperator
with a custom handler for checked exceptions.static java.util.function.IntConsumer
intConsumer(CheckedIntConsumer consumer)
Wrap aCheckedIntConsumer
in aIntConsumer
.static java.util.function.IntConsumer
intConsumer(CheckedIntConsumer consumer, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedIntConsumer
in aIntConsumer
with a custom handler for checked exceptions.static <R> java.util.function.IntFunction<R>
intFunction(CheckedIntFunction<R> function)
Wrap aCheckedIntFunction
in aIntFunction
.static <R> java.util.function.IntFunction<R>
intFunction(CheckedIntFunction<R> function, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedIntFunction
in aIntFunction
with a custom handler for checked exceptions.static java.util.function.IntPredicate
intPredicate(CheckedIntPredicate predicate)
Wrap aCheckedPredicate
in aIntPredicate
.static java.util.function.IntPredicate
intPredicate(CheckedIntPredicate function, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedPredicate
in aIntPredicate
with a custom handler for checked exceptions.static java.util.function.IntSupplier
intSupplier(CheckedIntSupplier supplier)
Wrap aCheckedIntSupplier
in aIntSupplier
.static java.util.function.IntSupplier
intSupplier(CheckedIntSupplier supplier, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedIntSupplier
in aIntSupplier
with a custom handler for checked exceptions.static java.util.function.IntToDoubleFunction
intToDoubleFunction(CheckedIntToDoubleFunction function)
Wrap aCheckedIntToDoubleFunction
in aIntToDoubleFunction
.static java.util.function.IntToDoubleFunction
intToDoubleFunction(CheckedIntToDoubleFunction function, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedIntToDoubleFunction
in aIntToDoubleFunction
with a custom handler for checked exceptions.static java.util.function.IntToLongFunction
intToLongFunction(CheckedIntToLongFunction function)
Wrap aCheckedIntToLongFunction
in aIntToLongFunction
.static java.util.function.IntToLongFunction
intToLongFunction(CheckedIntToLongFunction function, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedIntToLongFunction
in aIntToLongFunction
with a custom handler for checked exceptions.static java.util.function.IntUnaryOperator
intUnaryOperator(CheckedIntUnaryOperator operator)
Wrap aCheckedIntUnaryOperator
in aIntUnaryOperator
.static java.util.function.IntUnaryOperator
intUnaryOperator(CheckedIntUnaryOperator operator, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedIntUnaryOperator
in aIntUnaryOperator
with a custom handler for checked exceptions.static java.util.function.LongBinaryOperator
longBinaryOperator(CheckedLongBinaryOperator operator)
Wrap aCheckedLongBinaryOperator
in aLongBinaryOperator
.static java.util.function.LongBinaryOperator
longBinaryOperator(CheckedLongBinaryOperator operator, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedLongBinaryOperator
in aLongBinaryOperator
with a custom handler for checked exceptions.static java.util.function.LongConsumer
longConsumer(CheckedLongConsumer consumer)
Wrap aCheckedLongConsumer
in aLongConsumer
.static java.util.function.LongConsumer
longConsumer(CheckedLongConsumer consumer, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedLongConsumer
in aLongConsumer
with a custom handler for checked exceptions.static <R> java.util.function.LongFunction<R>
longFunction(CheckedLongFunction<R> function)
Wrap aCheckedLongFunction
in aLongFunction
.static <R> java.util.function.LongFunction<R>
longFunction(CheckedLongFunction<R> function, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedLongFunction
in aLongFunction
with a custom handler for checked exceptions.static java.util.function.LongPredicate
longPredicate(CheckedLongPredicate predicate)
Wrap aCheckedLongPredicate
in aLongPredicate
.static java.util.function.LongPredicate
longPredicate(CheckedLongPredicate function, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedLongPredicate
in aLongPredicate
with a custom handler for checked exceptions.static java.util.function.LongSupplier
longSupplier(CheckedLongSupplier supplier)
Wrap aCheckedLongSupplier
in aLongSupplier
.static java.util.function.LongSupplier
longSupplier(CheckedLongSupplier supplier, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedLongSupplier
in aLongSupplier
with a custom handler for checked exceptions.static java.util.function.LongToDoubleFunction
longToDoubleFunction(CheckedLongToDoubleFunction function)
Wrap aCheckedLongToDoubleFunction
in aLongToDoubleFunction
.static java.util.function.LongToDoubleFunction
longToDoubleFunction(CheckedLongToDoubleFunction function, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedLongToDoubleFunction
in aLongToDoubleFunction
with a custom handler for checked exceptions.static java.util.function.LongToIntFunction
longToIntFunction(CheckedLongToIntFunction function)
Wrap aCheckedLongToIntFunction
in aLongToIntFunction
.static java.util.function.LongToIntFunction
longToIntFunction(CheckedLongToIntFunction function, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedLongToIntFunction
in aLongToIntFunction
with a custom handler for checked exceptions.static java.util.function.LongUnaryOperator
longUnaryOperator(CheckedLongUnaryOperator operator)
Wrap aCheckedLongUnaryOperator
in aLongUnaryOperator
.static java.util.function.LongUnaryOperator
longUnaryOperator(CheckedLongUnaryOperator operator, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedLongUnaryOperator
in aLongUnaryOperator
with a custom handler for checked exceptions.static <T> java.util.function.ObjDoubleConsumer<T>
objDoubleConsumer(CheckedObjDoubleConsumer<T> consumer)
Wrap aCheckedObjDoubleConsumer
in aObjDoubleConsumer
.static <T> java.util.function.ObjDoubleConsumer<T>
objDoubleConsumer(CheckedObjDoubleConsumer<T> consumer, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedObjDoubleConsumer
in aObjDoubleConsumer
with a custom handler for checked exceptions.static <T> java.util.function.ObjIntConsumer<T>
objIntConsumer(CheckedObjIntConsumer<T> consumer)
Wrap aCheckedObjIntConsumer
in aObjIntConsumer
.static <T> java.util.function.ObjIntConsumer<T>
objIntConsumer(CheckedObjIntConsumer<T> consumer, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedObjIntConsumer
in aObjIntConsumer
with a custom handler for checked exceptions.static <T> java.util.function.ObjLongConsumer<T>
objLongConsumer(CheckedObjLongConsumer<T> consumer)
Wrap aCheckedObjLongConsumer
in aObjLongConsumer
.static <T> java.util.function.ObjLongConsumer<T>
objLongConsumer(CheckedObjLongConsumer<T> consumer, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedObjLongConsumer
in aObjLongConsumer
with a custom handler for checked exceptions.static <T> java.util.function.Predicate<T>
predicate(CheckedPredicate<T> predicate)
Wrap aCheckedPredicate
in aPredicate
.static <T> java.util.function.Predicate<T>
predicate(CheckedPredicate<T> function, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedPredicate
in aPredicate
with a custom handler for checked exceptions.static java.lang.Runnable
runnable(CheckedRunnable runnable)
Wrap aCheckedRunnable
in aRunnable
.static java.lang.Runnable
runnable(CheckedRunnable runnable, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedRunnable
in aRunnable
with a custom handler for checked exceptions.static <T> java.util.function.Supplier<T>
supplier(CheckedSupplier<T> supplier)
Wrap aCheckedSupplier
in aSupplier
.static <T> java.util.function.Supplier<T>
supplier(CheckedSupplier<T> supplier, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedSupplier
in aSupplier
with a custom handler for checked exceptions.static void
throwChecked(java.lang.Throwable t)
"sneaky-throw" a checked exception or throwable.static <T,U>
java.util.function.ToDoubleBiFunction<T,U>toDoubleBiFunction(CheckedToDoubleBiFunction<T,U> function)
Wrap aCheckedToDoubleBiFunction
in aToDoubleBiFunction
.static <T,U>
java.util.function.ToDoubleBiFunction<T,U>toDoubleBiFunction(CheckedToDoubleBiFunction<T,U> function, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedToDoubleBiFunction
in aToDoubleBiFunction
with a custom handler for checked exceptions.static <T> java.util.function.ToDoubleFunction<T>
toDoubleFunction(CheckedToDoubleFunction<T> function)
Wrap aCheckedToDoubleFunction
in aToDoubleFunction
.static <T> java.util.function.ToDoubleFunction<T>
toDoubleFunction(CheckedToDoubleFunction<T> function, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedToDoubleFunction
in aToDoubleFunction
with a custom handler for checked exceptions.static <T,U>
java.util.function.ToIntBiFunction<T,U>toIntBiFunction(CheckedToIntBiFunction<T,U> function)
Wrap aCheckedToIntBiFunction
in aToIntBiFunction
.static <T,U>
java.util.function.ToIntBiFunction<T,U>toIntBiFunction(CheckedToIntBiFunction<T,U> function, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedToIntBiFunction
in aToIntBiFunction
with a custom handler for checked exceptions.static <T> java.util.function.ToIntFunction<T>
toIntFunction(CheckedToIntFunction<T> function)
Wrap aCheckedToIntFunction
in aToIntFunction
.static <T> java.util.function.ToIntFunction<T>
toIntFunction(CheckedToIntFunction<T> function, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedToIntFunction
in aToIntFunction
with a custom handler for checked exceptions.static <T,U>
java.util.function.ToLongBiFunction<T,U>toLongBiFunction(CheckedToLongBiFunction<T,U> function)
Wrap aCheckedToLongBiFunction
in aToLongBiFunction
.static <T,U>
java.util.function.ToLongBiFunction<T,U>toLongBiFunction(CheckedToLongBiFunction<T,U> function, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedToLongBiFunction
in aToLongBiFunction
with a custom handler for checked exceptions.static <T> java.util.function.ToLongFunction<T>
toLongFunction(CheckedToLongFunction<T> function)
Wrap aCheckedToLongFunction
in aToLongFunction
.static <T> java.util.function.ToLongFunction<T>
toLongFunction(CheckedToLongFunction<T> function, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedToLongFunction
in aToLongFunction
with a custom handler for checked exceptions.static <T> java.util.function.UnaryOperator<T>
unaryOperator(CheckedUnaryOperator<T> operator)
Wrap aCheckedUnaryOperator
in aUnaryOperator
.static <T> java.util.function.UnaryOperator<T>
unaryOperator(CheckedUnaryOperator<T> operator, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedUnaryOperator
in aUnaryOperator
with a custom handler for checked exceptions.
-
-
-
Field Detail
-
THROWABLE_TO_RUNTIME_EXCEPTION
public static final java.util.function.Consumer<java.lang.Throwable> THROWABLE_TO_RUNTIME_EXCEPTION
AConsumer
that wraps anyThrowable
in aRuntimeException
.
-
RETHROW_ALL
public static final java.util.function.Consumer<java.lang.Throwable> RETHROW_ALL
AConsumer
that rethrows all exceptions, including checked exceptions.
-
-
Method Detail
-
throwChecked
public static void throwChecked(java.lang.Throwable t)
"sneaky-throw" a checked exception or throwable.
-
runnable
public static java.lang.Runnable runnable(CheckedRunnable runnable)
Wrap aCheckedRunnable
in aRunnable
.Example:
new Thread(Unchecked.runnable(() -> { throw new Exception("Cannot run this thread"); })).start();
-
runnable
public static java.lang.Runnable runnable(CheckedRunnable runnable, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedRunnable
in aRunnable
with a custom handler for checked exceptions.Example:
new Thread(Unchecked.runnable( () -> { throw new Exception("Cannot run this thread"); }, e -> { throw new IllegalStateException(e); } )).start();
-
callable
public static <T> java.util.concurrent.Callable<T> callable(CheckedCallable<T> callable)
Wrap aCheckedCallable
in aCallable
.Example:
Executors.newFixedThreadPool(1).submit(Unchecked.callable(() -> { throw new Exception("Cannot execute this task"); })).get();
-
callable
public static <T> java.util.concurrent.Callable<T> callable(CheckedCallable<T> callable, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedCallable
in aCallable
with a custom handler for checked exceptions.Example:
Executors.newFixedThreadPool(1).submit(Unchecked.callable( () -> { throw new Exception("Cannot execute this task"); }, e -> { throw new IllegalStateException(e); } )).get();
-
comparator
public static <T> java.util.Comparator<T> comparator(CheckedComparator<T> comparator)
Wrap aCheckedComparator
in aComparator
.
-
comparator
public static <T> java.util.Comparator<T> comparator(CheckedComparator<T> comparator, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedComparator
in aComparator
with a custom handler for checked exceptions.
-
biConsumer
public static <T,U> java.util.function.BiConsumer<T,U> biConsumer(CheckedBiConsumer<T,U> consumer)
Wrap aCheckedBiConsumer
in aBiConsumer
.Example:
map.forEach(Unchecked.biConsumer((k, v) -> { if (k == null || v == null) throw new Exception("No nulls allowed in map"); }));
-
biConsumer
public static <T,U> java.util.function.BiConsumer<T,U> biConsumer(CheckedBiConsumer<T,U> consumer, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedBiConsumer
in aBiConsumer
with a custom handler for checked exceptions.Example:
map.forEach(Unchecked.biConsumer( (k, v) -> { if (k == null || v == null) throw new Exception("No nulls allowed in map"); }, e -> { throw new IllegalStateException(e); } ));
-
objIntConsumer
public static <T> java.util.function.ObjIntConsumer<T> objIntConsumer(CheckedObjIntConsumer<T> consumer)
Wrap aCheckedObjIntConsumer
in aObjIntConsumer
.
-
objIntConsumer
public static <T> java.util.function.ObjIntConsumer<T> objIntConsumer(CheckedObjIntConsumer<T> consumer, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedObjIntConsumer
in aObjIntConsumer
with a custom handler for checked exceptions.
-
objLongConsumer
public static <T> java.util.function.ObjLongConsumer<T> objLongConsumer(CheckedObjLongConsumer<T> consumer)
Wrap aCheckedObjLongConsumer
in aObjLongConsumer
.
-
objLongConsumer
public static <T> java.util.function.ObjLongConsumer<T> objLongConsumer(CheckedObjLongConsumer<T> consumer, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedObjLongConsumer
in aObjLongConsumer
with a custom handler for checked exceptions.
-
objDoubleConsumer
public static <T> java.util.function.ObjDoubleConsumer<T> objDoubleConsumer(CheckedObjDoubleConsumer<T> consumer)
Wrap aCheckedObjDoubleConsumer
in aObjDoubleConsumer
.
-
objDoubleConsumer
public static <T> java.util.function.ObjDoubleConsumer<T> objDoubleConsumer(CheckedObjDoubleConsumer<T> consumer, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedObjDoubleConsumer
in aObjDoubleConsumer
with a custom handler for checked exceptions.
-
biFunction
public static <T,U,R> java.util.function.BiFunction<T,U,R> biFunction(CheckedBiFunction<T,U,R> function)
Wrap aCheckedBiFunction
in aBiFunction
.Example:
map.computeIfPresent("key", Unchecked.biFunction((k, v) -> { if (k == null || v == null) throw new Exception("No nulls allowed in map"); return 42; }));
-
biFunction
public static <T,U,R> java.util.function.BiFunction<T,U,R> biFunction(CheckedBiFunction<T,U,R> function, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedBiFunction
in aBiFunction
with a custom handler for checked exceptions.Example:
map.computeIfPresent("key", Unchecked.biFunction( (k, v) -> { if (k == null || v == null) throw new Exception("No nulls allowed in map"); return 42; }, e -> { throw new IllegalStateException(e); } ));
-
toIntBiFunction
public static <T,U> java.util.function.ToIntBiFunction<T,U> toIntBiFunction(CheckedToIntBiFunction<T,U> function)
Wrap aCheckedToIntBiFunction
in aToIntBiFunction
.
-
toIntBiFunction
public static <T,U> java.util.function.ToIntBiFunction<T,U> toIntBiFunction(CheckedToIntBiFunction<T,U> function, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedToIntBiFunction
in aToIntBiFunction
with a custom handler for checked exceptions.
-
toLongBiFunction
public static <T,U> java.util.function.ToLongBiFunction<T,U> toLongBiFunction(CheckedToLongBiFunction<T,U> function)
Wrap aCheckedToLongBiFunction
in aToLongBiFunction
.
-
toLongBiFunction
public static <T,U> java.util.function.ToLongBiFunction<T,U> toLongBiFunction(CheckedToLongBiFunction<T,U> function, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedToLongBiFunction
in aToLongBiFunction
with a custom handler for checked exceptions.
-
toDoubleBiFunction
public static <T,U> java.util.function.ToDoubleBiFunction<T,U> toDoubleBiFunction(CheckedToDoubleBiFunction<T,U> function)
Wrap aCheckedToDoubleBiFunction
in aToDoubleBiFunction
.
-
toDoubleBiFunction
public static <T,U> java.util.function.ToDoubleBiFunction<T,U> toDoubleBiFunction(CheckedToDoubleBiFunction<T,U> function, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedToDoubleBiFunction
in aToDoubleBiFunction
with a custom handler for checked exceptions.
-
biPredicate
public static <T,U> java.util.function.BiPredicate<T,U> biPredicate(CheckedBiPredicate<T,U> predicate)
Wrap aCheckedBiPredicate
in aBiPredicate
.
-
biPredicate
public static <T,U> java.util.function.BiPredicate<T,U> biPredicate(CheckedBiPredicate<T,U> predicate, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedBiPredicate
in aBiPredicate
with a custom handler for checked exceptions.
-
binaryOperator
public static <T> java.util.function.BinaryOperator<T> binaryOperator(CheckedBinaryOperator<T> operator)
Wrap aCheckedBinaryOperator
in aBinaryOperator
.Example:
Stream.of("a", "b", "c").reduce(Unchecked.binaryOperator((s1, s2) -> { if (s2.length() > 10) throw new Exception("Only short strings allowed"); return s1 + s2; }));
-
binaryOperator
public static <T> java.util.function.BinaryOperator<T> binaryOperator(CheckedBinaryOperator<T> operator, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedBinaryOperator
in aBinaryOperator
with a custom handler for checked exceptions.Example:
Stream.of("a", "b", "c").reduce(Unchecked.binaryOperator( (s1, s2) -> { if (s2.length() > 10) throw new Exception("Only short strings allowed"); return s1 + s2; }, e -> { throw new IllegalStateException(e); } ));
-
intBinaryOperator
public static java.util.function.IntBinaryOperator intBinaryOperator(CheckedIntBinaryOperator operator)
Wrap aCheckedIntBinaryOperator
in aIntBinaryOperator
.Example:
IntStream.of(1, 2, 3).reduce(Unchecked.intBinaryOperator((i1, i2) -> { if (i2 < 0) throw new Exception("Only positive numbers allowed"); return i1 + i2; }));
-
intBinaryOperator
public static java.util.function.IntBinaryOperator intBinaryOperator(CheckedIntBinaryOperator operator, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedIntBinaryOperator
in aIntBinaryOperator
with a custom handler for checked exceptions.Example:
IntStream.of(1, 2, 3).reduce(Unchecked.intBinaryOperator( (i1, i2) -> { if (i2 < 0) throw new Exception("Only positive numbers allowed"); return i1 + i2; }, e -> { throw new IllegalStateException(e); } ));
-
longBinaryOperator
public static java.util.function.LongBinaryOperator longBinaryOperator(CheckedLongBinaryOperator operator)
Wrap aCheckedLongBinaryOperator
in aLongBinaryOperator
.Example:
LongStream.of(1L, 2L, 3L).reduce(Unchecked.longBinaryOperator((l1, l2) -> { if (l2 < 0L) throw new Exception("Only positive numbers allowed"); return l1 + l2; }));
-
longBinaryOperator
public static java.util.function.LongBinaryOperator longBinaryOperator(CheckedLongBinaryOperator operator, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedLongBinaryOperator
in aLongBinaryOperator
with a custom handler for checked exceptions.Example:
LongStream.of(1L, 2L, 3L).reduce(Unchecked.longBinaryOperator( (l1, l2) -> { if (l2 < 0L) throw new Exception("Only positive numbers allowed"); return l1 + l2; }, e -> { throw new IllegalStateException(e); } ));
-
doubleBinaryOperator
public static java.util.function.DoubleBinaryOperator doubleBinaryOperator(CheckedDoubleBinaryOperator operator)
Wrap aCheckedDoubleBinaryOperator
in aDoubleBinaryOperator
.Example:
DoubleStream.of(1.0, 2.0, 3.0).reduce(Unchecked.doubleBinaryOperator((d1, d2) -> { if (d2 < 0.0) throw new Exception("Only positive numbers allowed"); return d1 + d2; }));
-
doubleBinaryOperator
public static java.util.function.DoubleBinaryOperator doubleBinaryOperator(CheckedDoubleBinaryOperator operator, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedDoubleBinaryOperator
in aDoubleBinaryOperator
with a custom handler for checked exceptions.Example:
DoubleStream.of(1.0, 2.0, 3.0).reduce(Unchecked.doubleBinaryOperator( (d1, d2) -> { if (d2 < 0.0) throw new Exception("Only positive numbers allowed"); return d1 + d2; }, e -> { throw new IllegalStateException(e); } ));
-
consumer
public static <T> java.util.function.Consumer<T> consumer(CheckedConsumer<T> consumer)
Wrap aCheckedConsumer
in aConsumer
.Example:
Arrays.asList("a", "b").stream().forEach(Unchecked.consumer(s -> { if (s.length() > 10) throw new Exception("Only short strings allowed"); }));
-
consumer
public static <T> java.util.function.Consumer<T> consumer(CheckedConsumer<T> consumer, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedConsumer
in aConsumer
with a custom handler for checked exceptions.Example:
Arrays.asList("a", "b").stream().forEach(Unchecked.consumer( s -> { if (s.length() > 10) throw new Exception("Only short strings allowed"); }, e -> { throw new IllegalStateException(e); } ));
-
intConsumer
public static java.util.function.IntConsumer intConsumer(CheckedIntConsumer consumer)
Wrap aCheckedIntConsumer
in aIntConsumer
.Example:
Arrays.stream(new int[] { 1, 2 }).forEach(Unchecked.intConsumer(i -> { if (i < 0) throw new Exception("Only positive numbers allowed"); }));
-
intConsumer
public static java.util.function.IntConsumer intConsumer(CheckedIntConsumer consumer, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedIntConsumer
in aIntConsumer
with a custom handler for checked exceptions.Example:
Arrays.stream(new int[] { 1, 2 }).forEach(Unchecked.intConsumer( i -> { if (i < 0) throw new Exception("Only positive numbers allowed"); }, e -> { throw new IllegalStateException(e); } ));
-
longConsumer
public static java.util.function.LongConsumer longConsumer(CheckedLongConsumer consumer)
Wrap aCheckedLongConsumer
in aLongConsumer
.Example:
Arrays.stream(new long[] { 1L, 2L }).forEach(Unchecked.longConsumer(l -> { if (l < 0) throw new Exception("Only positive numbers allowed"); }));
-
longConsumer
public static java.util.function.LongConsumer longConsumer(CheckedLongConsumer consumer, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedLongConsumer
in aLongConsumer
with a custom handler for checked exceptions.Example:
Arrays.stream(new long[] { 1L, 2L }).forEach(Unchecked.longConsumer( l -> { if (l < 0) throw new Exception("Only positive numbers allowed"); }, e -> { throw new IllegalStateException(e); } ));
-
doubleConsumer
public static java.util.function.DoubleConsumer doubleConsumer(CheckedDoubleConsumer consumer)
Wrap aCheckedDoubleConsumer
in aDoubleConsumer
.Example:
Arrays.stream(new double[] { 1.0, 2.0 }).forEach(Unchecked.doubleConsumer(d -> { if (d < 0.0) throw new Exception("Only positive numbers allowed"); }));
-
doubleConsumer
public static java.util.function.DoubleConsumer doubleConsumer(CheckedDoubleConsumer consumer, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedDoubleConsumer
in aDoubleConsumer
with a custom handler for checked exceptions.Example:
Arrays.stream(new double[] { 1.0, 2.0 }).forEach(Unchecked.doubleConsumer( d -> { if (d < 0.0) throw new Exception("Only positive numbers allowed"); }, e -> { throw new IllegalStateException(e); } ));
-
function
public static <T,R> java.util.function.Function<T,R> function(CheckedFunction<T,R> function)
Wrap aCheckedFunction
in aFunction
.Example:
map.computeIfAbsent("key", Unchecked.function(k -> { if (k.length() > 10) throw new Exception("Only short strings allowed"); return 42; }));
-
function
public static <T,R> java.util.function.Function<T,R> function(CheckedFunction<T,R> function, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedFunction
in aFunction
with a custom handler for checked exceptions.Example:
map.forEach(Unchecked.function( k -> { if (k.length() > 10) throw new Exception("Only short strings allowed"); return 42; }, e -> { throw new IllegalStateException(e); } ));
-
toIntFunction
public static <T> java.util.function.ToIntFunction<T> toIntFunction(CheckedToIntFunction<T> function)
Wrap aCheckedToIntFunction
in aToIntFunction
.Example:
map.computeIfAbsent("key", Unchecked.toIntFunction(k -> { if (k.length() > 10) throw new Exception("Only short strings allowed"); return 42; }));
-
toIntFunction
public static <T> java.util.function.ToIntFunction<T> toIntFunction(CheckedToIntFunction<T> function, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedToIntFunction
in aToIntFunction
with a custom handler for checked exceptions.Example:
map.forEach(Unchecked.toIntFunction( k -> { if (k.length() > 10) throw new Exception("Only short strings allowed"); return 42; }, e -> { throw new IllegalStateException(e); } ));
-
toLongFunction
public static <T> java.util.function.ToLongFunction<T> toLongFunction(CheckedToLongFunction<T> function)
Wrap aCheckedToLongFunction
in aToLongFunction
.Example:
map.computeIfAbsent("key", Unchecked.toLongFunction(k -> { if (k.length() > 10) throw new Exception("Only short strings allowed"); return 42L; }));
-
toLongFunction
public static <T> java.util.function.ToLongFunction<T> toLongFunction(CheckedToLongFunction<T> function, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedToLongFunction
in aToLongFunction
with a custom handler for checked exceptions.Example:
map.forEach(Unchecked.toLongFunction( k -> { if (k.length() > 10) throw new Exception("Only short strings allowed"); return 42L; }, e -> { throw new IllegalStateException(e); } ));
-
toDoubleFunction
public static <T> java.util.function.ToDoubleFunction<T> toDoubleFunction(CheckedToDoubleFunction<T> function)
Wrap aCheckedToDoubleFunction
in aToDoubleFunction
.Example:
map.computeIfAbsent("key", Unchecked.toDoubleFunction(k -> { if (k.length() > 10) throw new Exception("Only short strings allowed"); return 42.0; }));
-
toDoubleFunction
public static <T> java.util.function.ToDoubleFunction<T> toDoubleFunction(CheckedToDoubleFunction<T> function, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedToDoubleFunction
in aToDoubleFunction
with a custom handler for checked exceptions.Example:
map.forEach(Unchecked.toDoubleFunction( k -> { if (k.length() > 10) throw new Exception("Only short strings allowed"); return 42.0; }, e -> { throw new IllegalStateException(e); } ));
-
intFunction
public static <R> java.util.function.IntFunction<R> intFunction(CheckedIntFunction<R> function)
Wrap aCheckedIntFunction
in aIntFunction
.Example:
IntStream.of(1, 2, 3).mapToObj(Unchecked.intFunction(i -> { if (i < 0) throw new Exception("Only positive numbers allowed"); return "" + i; });
-
intFunction
public static <R> java.util.function.IntFunction<R> intFunction(CheckedIntFunction<R> function, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedIntFunction
in aIntFunction
with a custom handler for checked exceptions.Example:
IntStream.of(1, 2, 3).mapToObj(Unchecked.intFunction( i -> { if (i < 0) throw new Exception("Only positive numbers allowed"); return "" + i; }, e -> { throw new IllegalStateException(e); } ));
-
intToLongFunction
public static java.util.function.IntToLongFunction intToLongFunction(CheckedIntToLongFunction function)
Wrap aCheckedIntToLongFunction
in aIntToLongFunction
.Example:
IntStream.of(1, 2, 3).mapToLong(Unchecked.intToLongFunction(i -> { if (i < 0) throw new Exception("Only positive numbers allowed"); return (long) i; });
-
intToLongFunction
public static java.util.function.IntToLongFunction intToLongFunction(CheckedIntToLongFunction function, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedIntToLongFunction
in aIntToLongFunction
with a custom handler for checked exceptions.Example:
IntStream.of(1, 2, 3).mapToLong(Unchecked.intToLongFunction( i -> { if (i < 0) throw new Exception("Only positive numbers allowed"); return (long) i; }, e -> { throw new IllegalStateException(e); } ));
-
intToDoubleFunction
public static java.util.function.IntToDoubleFunction intToDoubleFunction(CheckedIntToDoubleFunction function)
Wrap aCheckedIntToDoubleFunction
in aIntToDoubleFunction
.Example:
IntStream.of(1, 2, 3).mapToDouble(Unchecked.intToDoubleFunction(i -> { if (i < 0) throw new Exception("Only positive numbers allowed"); return (double) i; });
-
intToDoubleFunction
public static java.util.function.IntToDoubleFunction intToDoubleFunction(CheckedIntToDoubleFunction function, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedIntToDoubleFunction
in aIntToDoubleFunction
with a custom handler for checked exceptions.Example:
IntStream.of(1, 2, 3).mapToDouble(Unchecked.intToDoubleFunction( i -> { if (i < 0) throw new Exception("Only positive numbers allowed"); return (double) i; }, e -> { throw new IllegalStateException(e); } ));
-
longFunction
public static <R> java.util.function.LongFunction<R> longFunction(CheckedLongFunction<R> function)
Wrap aCheckedLongFunction
in aLongFunction
.Example:
LongStream.of(1L, 2L, 3L).mapToObj(Unchecked.longFunction(l -> { if (l < 0L) throw new Exception("Only positive numbers allowed"); return "" + l; });
-
longFunction
public static <R> java.util.function.LongFunction<R> longFunction(CheckedLongFunction<R> function, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedLongFunction
in aLongFunction
with a custom handler for checked exceptions.Example:
LongStream.of(1L, 2L, 3L).mapToObj(Unchecked.longFunction( l -> { if (l < 0L) throw new Exception("Only positive numbers allowed"); return "" + l; }, e -> { throw new IllegalStateException(e); } ));
-
longToIntFunction
public static java.util.function.LongToIntFunction longToIntFunction(CheckedLongToIntFunction function)
Wrap aCheckedLongToIntFunction
in aLongToIntFunction
.Example:
LongStream.of(1L, 2L, 3L).mapToInt(Unchecked.longToIntFunction(l -> { if (l < 0L) throw new Exception("Only positive numbers allowed"); return (int) l; });
-
longToIntFunction
public static java.util.function.LongToIntFunction longToIntFunction(CheckedLongToIntFunction function, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedLongToIntFunction
in aLongToIntFunction
with a custom handler for checked exceptions.Example:
LongStream.of(1L, 2L, 3L).mapToInt(Unchecked.longToIntFunction( l -> { if (l < 0L) throw new Exception("Only positive numbers allowed"); return (int) l; }, e -> { throw new IllegalStateException(e); } ));
-
longToDoubleFunction
public static java.util.function.LongToDoubleFunction longToDoubleFunction(CheckedLongToDoubleFunction function)
Wrap aCheckedLongToDoubleFunction
in aLongToDoubleFunction
.Example:
LongStream.of(1L, 2L, 3L).mapToInt(Unchecked.longToDoubleFunction(l -> { if (l < 0L) throw new Exception("Only positive numbers allowed"); return (double) l; });
-
longToDoubleFunction
public static java.util.function.LongToDoubleFunction longToDoubleFunction(CheckedLongToDoubleFunction function, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedLongToDoubleFunction
in aLongToDoubleFunction
with a custom handler for checked exceptions.Example:
LongStream.of(1L, 2L, 3L).mapToInt(Unchecked.longToDoubleFunction( l -> { if (l < 0L) throw new Exception("Only positive numbers allowed"); return (double) l; }, e -> { throw new IllegalStateException(e); } ));
-
doubleFunction
public static <R> java.util.function.DoubleFunction<R> doubleFunction(CheckedDoubleFunction<R> function)
Wrap aCheckedDoubleFunction
in aDoubleFunction
.Example:
DoubleStream.of(1.0, 2.0, 3.0).mapToObj(Unchecked.doubleFunction(d -> { if (d < 0.0) throw new Exception("Only positive numbers allowed"); return "" + d; });
-
doubleFunction
public static <R> java.util.function.DoubleFunction<R> doubleFunction(CheckedDoubleFunction<R> function, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedDoubleFunction
in aDoubleFunction
with a custom handler for checked exceptions.Example:
DoubleStream.of(1.0, 2.0, 3.0).mapToObj(Unchecked.doubleFunction( d -> { if (d < 0.0) throw new Exception("Only positive numbers allowed"); return "" + d; }, e -> { throw new IllegalStateException(e); } ));
-
doubleToIntFunction
public static java.util.function.DoubleToIntFunction doubleToIntFunction(CheckedDoubleToIntFunction function)
Wrap aCheckedDoubleToIntFunction
in aDoubleToIntFunction
.Example:
DoubleStream.of(1.0, 2.0, 3.0).mapToInt(Unchecked.doubleToIntFunction(d -> { if (d < 0.0) throw new Exception("Only positive numbers allowed"); return (int) d; });
-
doubleToIntFunction
public static java.util.function.DoubleToIntFunction doubleToIntFunction(CheckedDoubleToIntFunction function, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedDoubleToIntFunction
in aDoubleToIntFunction
with a custom handler for checked exceptions.Example:
DoubleStream.of(1.0, 2.0, 3.0).mapToInt(Unchecked.doubleToIntFunction( d -> { if (d < 0.0) throw new Exception("Only positive numbers allowed"); return (int) d; }, e -> { throw new IllegalStateException(e); } ));
-
doubleToLongFunction
public static java.util.function.DoubleToLongFunction doubleToLongFunction(CheckedDoubleToLongFunction function)
Wrap aCheckedDoubleToLongFunction
in aDoubleToLongFunction
.Example:
DoubleStream.of(1.0, 2.0, 3.0).mapToLong(Unchecked.doubleToLongFunction(d -> { if (d < 0.0) throw new Exception("Only positive numbers allowed"); return (long) d; });
-
doubleToLongFunction
public static java.util.function.DoubleToLongFunction doubleToLongFunction(CheckedDoubleToLongFunction function, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedDoubleToLongFunction
in aDoubleToLongFunction
with a custom handler for checked exceptions.Example:
DoubleStream.of(1.0, 2.0, 3.0).mapToLong(Unchecked.doubleToLongFunction( d -> { if (d < 0.0) throw new Exception("Only positive numbers allowed"); return (long) d; }, e -> { throw new IllegalStateException(e); } ));
-
predicate
public static <T> java.util.function.Predicate<T> predicate(CheckedPredicate<T> predicate)
Wrap aCheckedPredicate
in aPredicate
.Example:
Stream.of("a", "b", "c").filter(Unchecked.predicate(s -> { if (s.length() > 10) throw new Exception("Only short strings allowed"); return true; }));
-
predicate
public static <T> java.util.function.Predicate<T> predicate(CheckedPredicate<T> function, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedPredicate
in aPredicate
with a custom handler for checked exceptions.Example:
Stream.of("a", "b", "c").filter(Unchecked.predicate( s -> { if (s.length() > 10) throw new Exception("Only short strings allowed"); return true; }, e -> { throw new IllegalStateException(e); } ));
-
intPredicate
public static java.util.function.IntPredicate intPredicate(CheckedIntPredicate predicate)
Wrap aCheckedPredicate
in aIntPredicate
.Example:
IntStream.of(1, 2, 3).filter(Unchecked.intPredicate(i -> { if (i < 0) throw new Exception("Only positive numbers allowed"); return true; }));
-
intPredicate
public static java.util.function.IntPredicate intPredicate(CheckedIntPredicate function, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedPredicate
in aIntPredicate
with a custom handler for checked exceptions.Example:
IntStream.of(1, 2, 3).filter(Unchecked.intPredicate( i -> { if (i < 0) throw new Exception("Only positive numbers allowed"); return true; }, e -> { throw new IllegalStateException(e); } ));
-
longPredicate
public static java.util.function.LongPredicate longPredicate(CheckedLongPredicate predicate)
Wrap aCheckedLongPredicate
in aLongPredicate
.Example:
LongStream.of(1L, 2L, 3L).filter(Unchecked.longPredicate(l -> { if (l < 0L) throw new Exception("Only positive numbers allowed"); return true; }));
-
longPredicate
public static java.util.function.LongPredicate longPredicate(CheckedLongPredicate function, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedLongPredicate
in aLongPredicate
with a custom handler for checked exceptions.Example:
LongStream.of(1L, 2L, 3L).filter(Unchecked.longPredicate( l -> { if (l < 0L) throw new Exception("Only positive numbers allowed"); return true; }, e -> { throw new IllegalStateException(e); } ));
-
doublePredicate
public static java.util.function.DoublePredicate doublePredicate(CheckedDoublePredicate predicate)
Wrap aCheckedDoublePredicate
in aDoublePredicate
.Example:
DoubleStream.of(1.0, 2.0, 3.0).filter(Unchecked.doublePredicate(d -> { if (d < 0.0) throw new Exception("Only positive numbers allowed"); return true; }));
-
doublePredicate
public static java.util.function.DoublePredicate doublePredicate(CheckedDoublePredicate function, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedDoublePredicate
in aDoublePredicate
with a custom handler for checked exceptions.Example:
DoubleStream.of(1.0, 2.0, 3.0).filter(Unchecked.doublePredicate( d -> { if (d < 0.0) throw new Exception("Only positive numbers allowed"); return true; }, e -> { throw new IllegalStateException(e); } ));
-
supplier
public static <T> java.util.function.Supplier<T> supplier(CheckedSupplier<T> supplier)
Wrap aCheckedSupplier
in aSupplier
.Example:
ResultSet rs = statement.executeQuery(); Stream.generate(Unchecked.supplier(() -> rs.getObject(1)));
-
supplier
public static <T> java.util.function.Supplier<T> supplier(CheckedSupplier<T> supplier, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedSupplier
in aSupplier
with a custom handler for checked exceptions.Example:
ResultSet rs = statement.executeQuery(); Stream.generate(Unchecked.supplier( () -> rs.getObject(1), e -> { throw new IllegalStateException(e); } ));
-
intSupplier
public static java.util.function.IntSupplier intSupplier(CheckedIntSupplier supplier)
Wrap aCheckedIntSupplier
in aIntSupplier
.Example:
ResultSet rs = statement.executeQuery(); Stream.generate(Unchecked.intSupplier(() -> rs.getInt(1)));
-
intSupplier
public static java.util.function.IntSupplier intSupplier(CheckedIntSupplier supplier, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedIntSupplier
in aIntSupplier
with a custom handler for checked exceptions.Example:
ResultSet rs = statement.executeQuery(); Stream.generate(Unchecked.intSupplier( () -> rs.getInt(1), e -> { throw new IllegalStateException(e); } ));
-
longSupplier
public static java.util.function.LongSupplier longSupplier(CheckedLongSupplier supplier)
Wrap aCheckedLongSupplier
in aLongSupplier
.Example:
ResultSet rs = statement.executeQuery(); Stream.generate(Unchecked.longSupplier(() -> rs.getLong(1)));
-
longSupplier
public static java.util.function.LongSupplier longSupplier(CheckedLongSupplier supplier, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedLongSupplier
in aLongSupplier
with a custom handler for checked exceptions.Example:
ResultSet rs = statement.executeQuery(); Stream.generate(Unchecked.longSupplier( () -> rs.getLong(1), e -> { throw new IllegalStateException(e); } ));
-
doubleSupplier
public static java.util.function.DoubleSupplier doubleSupplier(CheckedDoubleSupplier supplier)
Wrap aCheckedDoubleSupplier
in aDoubleSupplier
.Example:
ResultSet rs = statement.executeQuery(); Stream.generate(Unchecked.doubleSupplier(() -> rs.getDouble(1)));
-
doubleSupplier
public static java.util.function.DoubleSupplier doubleSupplier(CheckedDoubleSupplier supplier, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedDoubleSupplier
in aDoubleSupplier
with a custom handler for checked exceptions.Example:
ResultSet rs = statement.executeQuery(); Stream.generate(Unchecked.doubleSupplier( () -> rs.getDouble(1), e -> { throw new IllegalStateException(e); } ));
-
booleanSupplier
public static java.util.function.BooleanSupplier booleanSupplier(CheckedBooleanSupplier supplier)
Wrap aCheckedBooleanSupplier
in aBooleanSupplier
.Example:
ResultSet rs = statement.executeQuery(); Stream.generate(Unchecked.booleanSupplier(() -> rs.getBoolean(1)));
-
booleanSupplier
public static java.util.function.BooleanSupplier booleanSupplier(CheckedBooleanSupplier supplier, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedBooleanSupplier
in aBooleanSupplier
with a custom handler for checked exceptions.Example:
ResultSet rs = statement.executeQuery(); Stream.generate(Unchecked.booleanSupplier( () -> rs.getBoolean(1), e -> { throw new IllegalStateException(e); } ));
-
unaryOperator
public static <T> java.util.function.UnaryOperator<T> unaryOperator(CheckedUnaryOperator<T> operator)
Wrap aCheckedUnaryOperator
in aUnaryOperator
.Example:
Stream.of("a", "b", "c").map(Unchecked.unaryOperator(s -> { if (s.length() > 10) throw new Exception("Only short strings allowed"); return s; }));
-
unaryOperator
public static <T> java.util.function.UnaryOperator<T> unaryOperator(CheckedUnaryOperator<T> operator, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedUnaryOperator
in aUnaryOperator
with a custom handler for checked exceptions.Example:
Stream.of("a", "b", "c").map(Unchecked.unaryOperator( s -> { if (s.length() > 10) throw new Exception("Only short strings allowed"); return s; }, e -> { throw new IllegalStateException(e); } ));
-
intUnaryOperator
public static java.util.function.IntUnaryOperator intUnaryOperator(CheckedIntUnaryOperator operator)
Wrap aCheckedIntUnaryOperator
in aIntUnaryOperator
.Example:
IntStream.of(1, 2, 3).map(Unchecked.intUnaryOperator(i -> { if (i < 0) throw new Exception("Only positive numbers allowed"); return i; }));
-
intUnaryOperator
public static java.util.function.IntUnaryOperator intUnaryOperator(CheckedIntUnaryOperator operator, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedIntUnaryOperator
in aIntUnaryOperator
with a custom handler for checked exceptions.Example:
IntStream.of(1, 2, 3).map(Unchecked.intUnaryOperator( i -> { if (i < 0) throw new Exception("Only positive numbers allowed"); return i; }, e -> { throw new IllegalStateException(e); } ));
-
longUnaryOperator
public static java.util.function.LongUnaryOperator longUnaryOperator(CheckedLongUnaryOperator operator)
Wrap aCheckedLongUnaryOperator
in aLongUnaryOperator
.Example:
LongStream.of(1L, 2L, 3L).map(Unchecked.longUnaryOperator(l -> { if (l < 0L) throw new Exception("Only positive numbers allowed"); return l; }));
-
longUnaryOperator
public static java.util.function.LongUnaryOperator longUnaryOperator(CheckedLongUnaryOperator operator, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedLongUnaryOperator
in aLongUnaryOperator
with a custom handler for checked exceptions.Example:
LongStream.of(1L, 2L, 3L).map(Unchecked.longUnaryOperator( l -> { if (l < 0L) throw new Exception("Only positive numbers allowed"); return l; }, e -> { throw new IllegalStateException(e); } ));
-
doubleUnaryOperator
public static java.util.function.DoubleUnaryOperator doubleUnaryOperator(CheckedDoubleUnaryOperator operator)
Wrap aCheckedDoubleUnaryOperator
in aDoubleUnaryOperator
.Example:
LongStream.of(1.0, 2.0, 3.0).map(Unchecked.doubleUnaryOperator(d -> { if (d < 0.0) throw new Exception("Only positive numbers allowed"); return d; }));
-
doubleUnaryOperator
public static java.util.function.DoubleUnaryOperator doubleUnaryOperator(CheckedDoubleUnaryOperator operator, java.util.function.Consumer<java.lang.Throwable> handler)
Wrap aCheckedDoubleUnaryOperator
in aDoubleUnaryOperator
with a custom handler for checked exceptions.Example:
LongStream.of(1.0, 2.0, 3.0).map(Unchecked.doubleUnaryOperator( d -> { if (d < 0.0) throw new Exception("Only positive numbers allowed"); return d; }, e -> { throw new IllegalStateException(e); } ));
-
-