public final class Unchecked
extends java.lang.Object
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.
Modifier and Type | Field | Description |
---|---|---|
static java.util.function.Consumer<java.lang.Throwable> |
RETHROW_ALL |
A
Consumer that rethrows all exceptions, including checked exceptions. |
static java.util.function.Consumer<java.lang.Throwable> |
THROWABLE_TO_RUNTIME_EXCEPTION |
A
Consumer that wraps any Throwable in a RuntimeException . |
Modifier and Type | Method | Description |
---|---|---|
static <T,U> java.util.function.BiConsumer<T,U> |
biConsumer(CheckedBiConsumer<T,U> consumer) |
Wrap a
CheckedBiConsumer in a BiConsumer . |
static <T,U> java.util.function.BiConsumer<T,U> |
biConsumer(CheckedBiConsumer<T,U> consumer,
java.util.function.Consumer<java.lang.Throwable> handler) |
Wrap a
CheckedBiConsumer in a BiConsumer 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 a
CheckedBiFunction in a BiFunction . |
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 a
CheckedBiFunction in a BiFunction with a custom handler for checked exceptions. |
static <T> java.util.function.BinaryOperator<T> |
binaryOperator(CheckedBinaryOperator<T> operator) |
Wrap a
CheckedBinaryOperator in a BinaryOperator . |
static <T> java.util.function.BinaryOperator<T> |
binaryOperator(CheckedBinaryOperator<T> operator,
java.util.function.Consumer<java.lang.Throwable> handler) |
Wrap a
CheckedBinaryOperator in a BinaryOperator with a custom handler for checked exceptions. |
static <T,U> java.util.function.BiPredicate<T,U> |
biPredicate(CheckedBiPredicate<T,U> predicate) |
Wrap a
CheckedBiPredicate in a BiPredicate . |
static <T,U> java.util.function.BiPredicate<T,U> |
biPredicate(CheckedBiPredicate<T,U> predicate,
java.util.function.Consumer<java.lang.Throwable> handler) |
Wrap a
CheckedBiPredicate in a BiPredicate with a custom handler for checked exceptions. |
static java.util.function.BooleanSupplier |
booleanSupplier(CheckedBooleanSupplier supplier) |
Wrap a
CheckedBooleanSupplier in a BooleanSupplier . |
static java.util.function.BooleanSupplier |
booleanSupplier(CheckedBooleanSupplier supplier,
java.util.function.Consumer<java.lang.Throwable> handler) |
Wrap a
CheckedBooleanSupplier in a BooleanSupplier with a custom handler for checked exceptions. |
static <T> java.util.concurrent.Callable<T> |
callable(CheckedCallable<T> callable) |
Wrap a
CheckedCallable in a Callable . |
static <T> java.util.concurrent.Callable<T> |
callable(CheckedCallable<T> callable,
java.util.function.Consumer<java.lang.Throwable> handler) |
Wrap a
CheckedCallable in a Callable with a custom handler for checked exceptions. |
static <T> java.util.Comparator<T> |
comparator(CheckedComparator<T> comparator) |
Wrap a
CheckedComparator in a Comparator . |
static <T> java.util.Comparator<T> |
comparator(CheckedComparator<T> comparator,
java.util.function.Consumer<java.lang.Throwable> handler) |
Wrap a
CheckedComparator in a Comparator with a custom handler for checked exceptions. |
static <T> java.util.function.Consumer<T> |
consumer(CheckedConsumer<T> consumer) |
Wrap a
CheckedConsumer in a Consumer . |
static <T> java.util.function.Consumer<T> |
consumer(CheckedConsumer<T> consumer,
java.util.function.Consumer<java.lang.Throwable> handler) |
Wrap a
CheckedConsumer in a Consumer with a custom handler for checked exceptions. |
static java.util.function.DoubleBinaryOperator |
doubleBinaryOperator(CheckedDoubleBinaryOperator operator) |
Wrap a
CheckedDoubleBinaryOperator in a DoubleBinaryOperator . |
static java.util.function.DoubleBinaryOperator |
doubleBinaryOperator(CheckedDoubleBinaryOperator operator,
java.util.function.Consumer<java.lang.Throwable> handler) |
Wrap a
CheckedDoubleBinaryOperator in a DoubleBinaryOperator with a custom handler for checked exceptions. |
static java.util.function.DoubleConsumer |
doubleConsumer(CheckedDoubleConsumer consumer) |
Wrap a
CheckedDoubleConsumer in a DoubleConsumer . |
static java.util.function.DoubleConsumer |
doubleConsumer(CheckedDoubleConsumer consumer,
java.util.function.Consumer<java.lang.Throwable> handler) |
Wrap a
CheckedDoubleConsumer in a DoubleConsumer with a custom handler for checked exceptions. |
static <R> java.util.function.DoubleFunction<R> |
doubleFunction(CheckedDoubleFunction<R> function) |
Wrap a
CheckedDoubleFunction in a DoubleFunction . |
static <R> java.util.function.DoubleFunction<R> |
doubleFunction(CheckedDoubleFunction<R> function,
java.util.function.Consumer<java.lang.Throwable> handler) |
Wrap a
CheckedDoubleFunction in a DoubleFunction with a custom handler for checked exceptions. |
static java.util.function.DoublePredicate |
doublePredicate(CheckedDoublePredicate predicate) |
Wrap a
CheckedDoublePredicate in a DoublePredicate . |
static java.util.function.DoublePredicate |
doublePredicate(CheckedDoublePredicate function,
java.util.function.Consumer<java.lang.Throwable> handler) |
Wrap a
CheckedDoublePredicate in a DoublePredicate with a custom handler for checked exceptions. |
static java.util.function.DoubleSupplier |
doubleSupplier(CheckedDoubleSupplier supplier) |
Wrap a
CheckedDoubleSupplier in a DoubleSupplier . |
static java.util.function.DoubleSupplier |
doubleSupplier(CheckedDoubleSupplier supplier,
java.util.function.Consumer<java.lang.Throwable> handler) |
Wrap a
CheckedDoubleSupplier in a DoubleSupplier with a custom handler for checked exceptions. |
static java.util.function.DoubleToIntFunction |
doubleToIntFunction(CheckedDoubleToIntFunction function) |
Wrap a
CheckedDoubleToIntFunction in a DoubleToIntFunction . |
static java.util.function.DoubleToIntFunction |
doubleToIntFunction(CheckedDoubleToIntFunction function,
java.util.function.Consumer<java.lang.Throwable> handler) |
Wrap a
CheckedDoubleToIntFunction in a DoubleToIntFunction with a custom handler for checked exceptions. |
static java.util.function.DoubleToLongFunction |
doubleToLongFunction(CheckedDoubleToLongFunction function) |
Wrap a
CheckedDoubleToLongFunction in a DoubleToLongFunction . |
static java.util.function.DoubleToLongFunction |
doubleToLongFunction(CheckedDoubleToLongFunction function,
java.util.function.Consumer<java.lang.Throwable> handler) |
Wrap a
CheckedDoubleToLongFunction in a DoubleToLongFunction with a custom handler for checked exceptions. |
static java.util.function.DoubleUnaryOperator |
doubleUnaryOperator(CheckedDoubleUnaryOperator operator) |
Wrap a
CheckedDoubleUnaryOperator in a DoubleUnaryOperator . |
static java.util.function.DoubleUnaryOperator |
doubleUnaryOperator(CheckedDoubleUnaryOperator operator,
java.util.function.Consumer<java.lang.Throwable> handler) |
Wrap a
CheckedDoubleUnaryOperator in a DoubleUnaryOperator with a custom handler for checked exceptions. |
static <T,R> java.util.function.Function<T,R> |
function(CheckedFunction<T,R> function) |
Wrap a
CheckedFunction in a Function . |
static <T,R> java.util.function.Function<T,R> |
function(CheckedFunction<T,R> function,
java.util.function.Consumer<java.lang.Throwable> handler) |
Wrap a
CheckedFunction in a Function with a custom handler for checked exceptions. |
static java.util.function.IntBinaryOperator |
intBinaryOperator(CheckedIntBinaryOperator operator) |
Wrap a
CheckedIntBinaryOperator in a IntBinaryOperator . |
static java.util.function.IntBinaryOperator |
intBinaryOperator(CheckedIntBinaryOperator operator,
java.util.function.Consumer<java.lang.Throwable> handler) |
Wrap a
CheckedIntBinaryOperator in a IntBinaryOperator with a custom handler for checked exceptions. |
static java.util.function.IntConsumer |
intConsumer(CheckedIntConsumer consumer) |
Wrap a
CheckedIntConsumer in a IntConsumer . |
static java.util.function.IntConsumer |
intConsumer(CheckedIntConsumer consumer,
java.util.function.Consumer<java.lang.Throwable> handler) |
Wrap a
CheckedIntConsumer in a IntConsumer with a custom handler for checked exceptions. |
static <R> java.util.function.IntFunction<R> |
intFunction(CheckedIntFunction<R> function) |
Wrap a
CheckedIntFunction in a IntFunction . |
static <R> java.util.function.IntFunction<R> |
intFunction(CheckedIntFunction<R> function,
java.util.function.Consumer<java.lang.Throwable> handler) |
Wrap a
CheckedIntFunction in a IntFunction with a custom handler for checked exceptions. |
static java.util.function.IntPredicate |
intPredicate(CheckedIntPredicate predicate) |
Wrap a
CheckedPredicate in a IntPredicate . |
static java.util.function.IntPredicate |
intPredicate(CheckedIntPredicate function,
java.util.function.Consumer<java.lang.Throwable> handler) |
Wrap a
CheckedPredicate in a IntPredicate with a custom handler for checked exceptions. |
static java.util.function.IntSupplier |
intSupplier(CheckedIntSupplier supplier) |
Wrap a
CheckedIntSupplier in a IntSupplier . |
static java.util.function.IntSupplier |
intSupplier(CheckedIntSupplier supplier,
java.util.function.Consumer<java.lang.Throwable> handler) |
Wrap a
CheckedIntSupplier in a IntSupplier with a custom handler for checked exceptions. |
static java.util.function.IntToDoubleFunction |
intToDoubleFunction(CheckedIntToDoubleFunction function) |
Wrap a
CheckedIntToDoubleFunction in a IntToDoubleFunction . |
static java.util.function.IntToDoubleFunction |
intToDoubleFunction(CheckedIntToDoubleFunction function,
java.util.function.Consumer<java.lang.Throwable> handler) |
Wrap a
CheckedIntToDoubleFunction in a IntToDoubleFunction with a custom handler for checked exceptions. |
static java.util.function.IntToLongFunction |
intToLongFunction(CheckedIntToLongFunction function) |
Wrap a
CheckedIntToLongFunction in a IntToLongFunction . |
static java.util.function.IntToLongFunction |
intToLongFunction(CheckedIntToLongFunction function,
java.util.function.Consumer<java.lang.Throwable> handler) |
Wrap a
CheckedIntToLongFunction in a IntToLongFunction with a custom handler for checked exceptions. |
static java.util.function.IntUnaryOperator |
intUnaryOperator(CheckedIntUnaryOperator operator) |
Wrap a
CheckedIntUnaryOperator in a IntUnaryOperator . |
static java.util.function.IntUnaryOperator |
intUnaryOperator(CheckedIntUnaryOperator operator,
java.util.function.Consumer<java.lang.Throwable> handler) |
Wrap a
CheckedIntUnaryOperator in a IntUnaryOperator with a custom handler for checked exceptions. |
static java.util.function.LongBinaryOperator |
longBinaryOperator(CheckedLongBinaryOperator operator) |
Wrap a
CheckedLongBinaryOperator in a LongBinaryOperator . |
static java.util.function.LongBinaryOperator |
longBinaryOperator(CheckedLongBinaryOperator operator,
java.util.function.Consumer<java.lang.Throwable> handler) |
Wrap a
CheckedLongBinaryOperator in a LongBinaryOperator with a custom handler for checked exceptions. |
static java.util.function.LongConsumer |
longConsumer(CheckedLongConsumer consumer) |
Wrap a
CheckedLongConsumer in a LongConsumer . |
static java.util.function.LongConsumer |
longConsumer(CheckedLongConsumer consumer,
java.util.function.Consumer<java.lang.Throwable> handler) |
Wrap a
CheckedLongConsumer in a LongConsumer with a custom handler for checked exceptions. |
static <R> java.util.function.LongFunction<R> |
longFunction(CheckedLongFunction<R> function) |
Wrap a
CheckedLongFunction in a LongFunction . |
static <R> java.util.function.LongFunction<R> |
longFunction(CheckedLongFunction<R> function,
java.util.function.Consumer<java.lang.Throwable> handler) |
Wrap a
CheckedLongFunction in a LongFunction with a custom handler for checked exceptions. |
static java.util.function.LongPredicate |
longPredicate(CheckedLongPredicate predicate) |
Wrap a
CheckedLongPredicate in a LongPredicate . |
static java.util.function.LongPredicate |
longPredicate(CheckedLongPredicate function,
java.util.function.Consumer<java.lang.Throwable> handler) |
Wrap a
CheckedLongPredicate in a LongPredicate with a custom handler for checked exceptions. |
static java.util.function.LongSupplier |
longSupplier(CheckedLongSupplier supplier) |
Wrap a
CheckedLongSupplier in a LongSupplier . |
static java.util.function.LongSupplier |
longSupplier(CheckedLongSupplier supplier,
java.util.function.Consumer<java.lang.Throwable> handler) |
Wrap a
CheckedLongSupplier in a LongSupplier with a custom handler for checked exceptions. |
static java.util.function.LongToDoubleFunction |
longToDoubleFunction(CheckedLongToDoubleFunction function) |
Wrap a
CheckedLongToDoubleFunction in a LongToDoubleFunction . |
static java.util.function.LongToDoubleFunction |
longToDoubleFunction(CheckedLongToDoubleFunction function,
java.util.function.Consumer<java.lang.Throwable> handler) |
Wrap a
CheckedLongToDoubleFunction in a LongToDoubleFunction with a custom handler for checked exceptions. |
static java.util.function.LongToIntFunction |
longToIntFunction(CheckedLongToIntFunction function) |
Wrap a
CheckedLongToIntFunction in a LongToIntFunction . |
static java.util.function.LongToIntFunction |
longToIntFunction(CheckedLongToIntFunction function,
java.util.function.Consumer<java.lang.Throwable> handler) |
Wrap a
CheckedLongToIntFunction in a LongToIntFunction with a custom handler for checked exceptions. |
static java.util.function.LongUnaryOperator |
longUnaryOperator(CheckedLongUnaryOperator operator) |
Wrap a
CheckedLongUnaryOperator in a LongUnaryOperator . |
static java.util.function.LongUnaryOperator |
longUnaryOperator(CheckedLongUnaryOperator operator,
java.util.function.Consumer<java.lang.Throwable> handler) |
Wrap a
CheckedLongUnaryOperator in a LongUnaryOperator with a custom handler for checked exceptions. |
static <T> java.util.function.ObjDoubleConsumer<T> |
objDoubleConsumer(CheckedObjDoubleConsumer<T> consumer) |
Wrap a
CheckedObjDoubleConsumer in a ObjDoubleConsumer . |
static <T> java.util.function.ObjDoubleConsumer<T> |
objDoubleConsumer(CheckedObjDoubleConsumer<T> consumer,
java.util.function.Consumer<java.lang.Throwable> handler) |
Wrap a
CheckedObjDoubleConsumer in a ObjDoubleConsumer with a custom handler for checked exceptions. |
static <T> java.util.function.ObjIntConsumer<T> |
objIntConsumer(CheckedObjIntConsumer<T> consumer) |
Wrap a
CheckedObjIntConsumer in a ObjIntConsumer . |
static <T> java.util.function.ObjIntConsumer<T> |
objIntConsumer(CheckedObjIntConsumer<T> consumer,
java.util.function.Consumer<java.lang.Throwable> handler) |
Wrap a
CheckedObjIntConsumer in a ObjIntConsumer with a custom handler for checked exceptions. |
static <T> java.util.function.ObjLongConsumer<T> |
objLongConsumer(CheckedObjLongConsumer<T> consumer) |
Wrap a
CheckedObjLongConsumer in a ObjLongConsumer . |
static <T> java.util.function.ObjLongConsumer<T> |
objLongConsumer(CheckedObjLongConsumer<T> consumer,
java.util.function.Consumer<java.lang.Throwable> handler) |
Wrap a
CheckedObjLongConsumer in a ObjLongConsumer with a custom handler for checked exceptions. |
static <T> java.util.function.Predicate<T> |
predicate(CheckedPredicate<T> predicate) |
Wrap a
CheckedPredicate in a Predicate . |
static <T> java.util.function.Predicate<T> |
predicate(CheckedPredicate<T> function,
java.util.function.Consumer<java.lang.Throwable> handler) |
Wrap a
CheckedPredicate in a Predicate with a custom handler for checked exceptions. |
static java.lang.Runnable |
runnable(CheckedRunnable runnable) |
Wrap a
CheckedRunnable in a Runnable . |
static java.lang.Runnable |
runnable(CheckedRunnable runnable,
java.util.function.Consumer<java.lang.Throwable> handler) |
Wrap a
CheckedRunnable in a Runnable with a custom handler for checked exceptions. |
static <T> java.util.function.Supplier<T> |
supplier(CheckedSupplier<T> supplier) |
Wrap a
CheckedSupplier in a Supplier . |
static <T> java.util.function.Supplier<T> |
supplier(CheckedSupplier<T> supplier,
java.util.function.Consumer<java.lang.Throwable> handler) |
Wrap a
CheckedSupplier in a Supplier 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 a
CheckedToDoubleBiFunction in a ToDoubleBiFunction . |
static <T,U> java.util.function.ToDoubleBiFunction<T,U> |
toDoubleBiFunction(CheckedToDoubleBiFunction<T,U> function,
java.util.function.Consumer<java.lang.Throwable> handler) |
Wrap a
CheckedToDoubleBiFunction in a ToDoubleBiFunction with a custom handler for checked exceptions. |
static <T> java.util.function.ToDoubleFunction<T> |
toDoubleFunction(CheckedToDoubleFunction<T> function) |
Wrap a
CheckedToDoubleFunction in a ToDoubleFunction . |
static <T> java.util.function.ToDoubleFunction<T> |
toDoubleFunction(CheckedToDoubleFunction<T> function,
java.util.function.Consumer<java.lang.Throwable> handler) |
Wrap a
CheckedToDoubleFunction in a ToDoubleFunction with a custom handler for checked exceptions. |
static <T,U> java.util.function.ToIntBiFunction<T,U> |
toIntBiFunction(CheckedToIntBiFunction<T,U> function) |
Wrap a
CheckedToIntBiFunction in a ToIntBiFunction . |
static <T,U> java.util.function.ToIntBiFunction<T,U> |
toIntBiFunction(CheckedToIntBiFunction<T,U> function,
java.util.function.Consumer<java.lang.Throwable> handler) |
Wrap a
CheckedToIntBiFunction in a ToIntBiFunction with a custom handler for checked exceptions. |
static <T> java.util.function.ToIntFunction<T> |
toIntFunction(CheckedToIntFunction<T> function) |
Wrap a
CheckedToIntFunction in a ToIntFunction . |
static <T> java.util.function.ToIntFunction<T> |
toIntFunction(CheckedToIntFunction<T> function,
java.util.function.Consumer<java.lang.Throwable> handler) |
Wrap a
CheckedToIntFunction in a ToIntFunction with a custom handler for checked exceptions. |
static <T,U> java.util.function.ToLongBiFunction<T,U> |
toLongBiFunction(CheckedToLongBiFunction<T,U> function) |
Wrap a
CheckedToLongBiFunction in a ToLongBiFunction . |
static <T,U> java.util.function.ToLongBiFunction<T,U> |
toLongBiFunction(CheckedToLongBiFunction<T,U> function,
java.util.function.Consumer<java.lang.Throwable> handler) |
Wrap a
CheckedToLongBiFunction in a ToLongBiFunction with a custom handler for checked exceptions. |
static <T> java.util.function.ToLongFunction<T> |
toLongFunction(CheckedToLongFunction<T> function) |
Wrap a
CheckedToLongFunction in a ToLongFunction . |
static <T> java.util.function.ToLongFunction<T> |
toLongFunction(CheckedToLongFunction<T> function,
java.util.function.Consumer<java.lang.Throwable> handler) |
Wrap a
CheckedToLongFunction in a ToLongFunction with a custom handler for checked exceptions. |
static <T> java.util.function.UnaryOperator<T> |
unaryOperator(CheckedUnaryOperator<T> operator) |
Wrap a
CheckedUnaryOperator in a UnaryOperator . |
static <T> java.util.function.UnaryOperator<T> |
unaryOperator(CheckedUnaryOperator<T> operator,
java.util.function.Consumer<java.lang.Throwable> handler) |
Wrap a
CheckedUnaryOperator in a UnaryOperator with a custom handler for checked exceptions. |
public static final java.util.function.Consumer<java.lang.Throwable> THROWABLE_TO_RUNTIME_EXCEPTION
Consumer
that wraps any Throwable
in a RuntimeException
.public static final java.util.function.Consumer<java.lang.Throwable> RETHROW_ALL
Consumer
that rethrows all exceptions, including checked exceptions.public static void throwChecked(java.lang.Throwable t)
public static java.lang.Runnable runnable(CheckedRunnable runnable)
CheckedRunnable
in a Runnable
.
Example:
new Thread(Unchecked.runnable(() -> {
throw new Exception("Cannot run this thread");
})).start();
public static java.lang.Runnable runnable(CheckedRunnable runnable, java.util.function.Consumer<java.lang.Throwable> handler)
CheckedRunnable
in a Runnable
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();
public static <T> java.util.concurrent.Callable<T> callable(CheckedCallable<T> callable)
CheckedCallable
in a Callable
.
Example:
Executors.newFixedThreadPool(1).submit(Unchecked.callable(() -> {
throw new Exception("Cannot execute this task");
})).get();
public static <T> java.util.concurrent.Callable<T> callable(CheckedCallable<T> callable, java.util.function.Consumer<java.lang.Throwable> handler)
CheckedCallable
in a Callable
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();
public static <T> java.util.Comparator<T> comparator(CheckedComparator<T> comparator)
CheckedComparator
in a Comparator
.public static <T> java.util.Comparator<T> comparator(CheckedComparator<T> comparator, java.util.function.Consumer<java.lang.Throwable> handler)
CheckedComparator
in a Comparator
with a custom handler for checked exceptions.public static <T,U> java.util.function.BiConsumer<T,U> biConsumer(CheckedBiConsumer<T,U> consumer)
CheckedBiConsumer
in a BiConsumer
.
Example:
map.forEach(Unchecked.biConsumer((k, v) -> {
if (k == null || v == null)
throw new Exception("No nulls allowed in map");
}));
public static <T,U> java.util.function.BiConsumer<T,U> biConsumer(CheckedBiConsumer<T,U> consumer, java.util.function.Consumer<java.lang.Throwable> handler)
CheckedBiConsumer
in a BiConsumer
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);
}
));
public static <T> java.util.function.ObjIntConsumer<T> objIntConsumer(CheckedObjIntConsumer<T> consumer)
CheckedObjIntConsumer
in a ObjIntConsumer
.public static <T> java.util.function.ObjIntConsumer<T> objIntConsumer(CheckedObjIntConsumer<T> consumer, java.util.function.Consumer<java.lang.Throwable> handler)
CheckedObjIntConsumer
in a ObjIntConsumer
with a custom handler for checked exceptions.public static <T> java.util.function.ObjLongConsumer<T> objLongConsumer(CheckedObjLongConsumer<T> consumer)
CheckedObjLongConsumer
in a ObjLongConsumer
.public static <T> java.util.function.ObjLongConsumer<T> objLongConsumer(CheckedObjLongConsumer<T> consumer, java.util.function.Consumer<java.lang.Throwable> handler)
CheckedObjLongConsumer
in a ObjLongConsumer
with a custom handler for checked exceptions.public static <T> java.util.function.ObjDoubleConsumer<T> objDoubleConsumer(CheckedObjDoubleConsumer<T> consumer)
CheckedObjDoubleConsumer
in a ObjDoubleConsumer
.public static <T> java.util.function.ObjDoubleConsumer<T> objDoubleConsumer(CheckedObjDoubleConsumer<T> consumer, java.util.function.Consumer<java.lang.Throwable> handler)
CheckedObjDoubleConsumer
in a ObjDoubleConsumer
with a custom handler for checked exceptions.public static <T,U,R> java.util.function.BiFunction<T,U,R> biFunction(CheckedBiFunction<T,U,R> function)
CheckedBiFunction
in a BiFunction
.
Example:
map.computeIfPresent("key", Unchecked.biFunction((k, v) -> {
if (k == null || v == null)
throw new Exception("No nulls allowed in map");
return 42;
}));
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)
CheckedBiFunction
in a BiFunction
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);
}
));
public static <T,U> java.util.function.ToIntBiFunction<T,U> toIntBiFunction(CheckedToIntBiFunction<T,U> function)
CheckedToIntBiFunction
in a ToIntBiFunction
.public static <T,U> java.util.function.ToIntBiFunction<T,U> toIntBiFunction(CheckedToIntBiFunction<T,U> function, java.util.function.Consumer<java.lang.Throwable> handler)
CheckedToIntBiFunction
in a ToIntBiFunction
with a custom handler for checked exceptions.public static <T,U> java.util.function.ToLongBiFunction<T,U> toLongBiFunction(CheckedToLongBiFunction<T,U> function)
CheckedToLongBiFunction
in a ToLongBiFunction
.public static <T,U> java.util.function.ToLongBiFunction<T,U> toLongBiFunction(CheckedToLongBiFunction<T,U> function, java.util.function.Consumer<java.lang.Throwable> handler)
CheckedToLongBiFunction
in a ToLongBiFunction
with a custom handler for checked exceptions.public static <T,U> java.util.function.ToDoubleBiFunction<T,U> toDoubleBiFunction(CheckedToDoubleBiFunction<T,U> function)
CheckedToDoubleBiFunction
in a ToDoubleBiFunction
.public static <T,U> java.util.function.ToDoubleBiFunction<T,U> toDoubleBiFunction(CheckedToDoubleBiFunction<T,U> function, java.util.function.Consumer<java.lang.Throwable> handler)
CheckedToDoubleBiFunction
in a ToDoubleBiFunction
with a custom handler for checked exceptions.public static <T,U> java.util.function.BiPredicate<T,U> biPredicate(CheckedBiPredicate<T,U> predicate)
CheckedBiPredicate
in a BiPredicate
.public static <T,U> java.util.function.BiPredicate<T,U> biPredicate(CheckedBiPredicate<T,U> predicate, java.util.function.Consumer<java.lang.Throwable> handler)
CheckedBiPredicate
in a BiPredicate
with a custom handler for checked exceptions.public static <T> java.util.function.BinaryOperator<T> binaryOperator(CheckedBinaryOperator<T> operator)
CheckedBinaryOperator
in a BinaryOperator
.
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;
}));
public static <T> java.util.function.BinaryOperator<T> binaryOperator(CheckedBinaryOperator<T> operator, java.util.function.Consumer<java.lang.Throwable> handler)
CheckedBinaryOperator
in a BinaryOperator
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);
}
));
public static java.util.function.IntBinaryOperator intBinaryOperator(CheckedIntBinaryOperator operator)
CheckedIntBinaryOperator
in a IntBinaryOperator
.
Example:
IntStream.of(1, 2, 3).reduce(Unchecked.intBinaryOperator((i1, i2) -> {
if (i2 < 0)
throw new Exception("Only positive numbers allowed");
return i1 + i2;
}));
public static java.util.function.IntBinaryOperator intBinaryOperator(CheckedIntBinaryOperator operator, java.util.function.Consumer<java.lang.Throwable> handler)
CheckedIntBinaryOperator
in a IntBinaryOperator
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);
}
));
public static java.util.function.LongBinaryOperator longBinaryOperator(CheckedLongBinaryOperator operator)
CheckedLongBinaryOperator
in a LongBinaryOperator
.
Example:
LongStream.of(1L, 2L, 3L).reduce(Unchecked.longBinaryOperator((l1, l2) -> {
if (l2 < 0L)
throw new Exception("Only positive numbers allowed");
return l1 + l2;
}));
public static java.util.function.LongBinaryOperator longBinaryOperator(CheckedLongBinaryOperator operator, java.util.function.Consumer<java.lang.Throwable> handler)
CheckedLongBinaryOperator
in a LongBinaryOperator
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);
}
));
public static java.util.function.DoubleBinaryOperator doubleBinaryOperator(CheckedDoubleBinaryOperator operator)
CheckedDoubleBinaryOperator
in a DoubleBinaryOperator
.
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;
}));
public static java.util.function.DoubleBinaryOperator doubleBinaryOperator(CheckedDoubleBinaryOperator operator, java.util.function.Consumer<java.lang.Throwable> handler)
CheckedDoubleBinaryOperator
in a DoubleBinaryOperator
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);
}
));
public static <T> java.util.function.Consumer<T> consumer(CheckedConsumer<T> consumer)
CheckedConsumer
in a Consumer
.
Example:
Arrays.asList("a", "b").stream().forEach(Unchecked.consumer(s -> {
if (s.length() > 10)
throw new Exception("Only short strings allowed");
}));
public static <T> java.util.function.Consumer<T> consumer(CheckedConsumer<T> consumer, java.util.function.Consumer<java.lang.Throwable> handler)
CheckedConsumer
in a Consumer
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);
}
));
public static java.util.function.IntConsumer intConsumer(CheckedIntConsumer consumer)
CheckedIntConsumer
in a IntConsumer
.
Example:
Arrays.stream(new int[] { 1, 2 }).forEach(Unchecked.intConsumer(i -> {
if (i < 0)
throw new Exception("Only positive numbers allowed");
}));
public static java.util.function.IntConsumer intConsumer(CheckedIntConsumer consumer, java.util.function.Consumer<java.lang.Throwable> handler)
CheckedIntConsumer
in a IntConsumer
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);
}
));
public static java.util.function.LongConsumer longConsumer(CheckedLongConsumer consumer)
CheckedLongConsumer
in a LongConsumer
.
Example:
Arrays.stream(new long[] { 1L, 2L }).forEach(Unchecked.longConsumer(l -> {
if (l < 0)
throw new Exception("Only positive numbers allowed");
}));
public static java.util.function.LongConsumer longConsumer(CheckedLongConsumer consumer, java.util.function.Consumer<java.lang.Throwable> handler)
CheckedLongConsumer
in a LongConsumer
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);
}
));
public static java.util.function.DoubleConsumer doubleConsumer(CheckedDoubleConsumer consumer)
CheckedDoubleConsumer
in a DoubleConsumer
.
Example:
Arrays.stream(new double[] { 1.0, 2.0 }).forEach(Unchecked.doubleConsumer(d -> {
if (d < 0.0)
throw new Exception("Only positive numbers allowed");
}));
public static java.util.function.DoubleConsumer doubleConsumer(CheckedDoubleConsumer consumer, java.util.function.Consumer<java.lang.Throwable> handler)
CheckedDoubleConsumer
in a DoubleConsumer
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);
}
));
public static <T,R> java.util.function.Function<T,R> function(CheckedFunction<T,R> function)
CheckedFunction
in a Function
.
Example:
map.computeIfAbsent("key", Unchecked.function(k -> {
if (k.length() > 10)
throw new Exception("Only short strings allowed");
return 42;
}));
public static <T,R> java.util.function.Function<T,R> function(CheckedFunction<T,R> function, java.util.function.Consumer<java.lang.Throwable> handler)
CheckedFunction
in a Function
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);
}
));
public static <T> java.util.function.ToIntFunction<T> toIntFunction(CheckedToIntFunction<T> function)
CheckedToIntFunction
in a ToIntFunction
.
Example:
map.computeIfAbsent("key", Unchecked.toIntFunction(k -> {
if (k.length() > 10)
throw new Exception("Only short strings allowed");
return 42;
}));
public static <T> java.util.function.ToIntFunction<T> toIntFunction(CheckedToIntFunction<T> function, java.util.function.Consumer<java.lang.Throwable> handler)
CheckedToIntFunction
in a ToIntFunction
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);
}
));
public static <T> java.util.function.ToLongFunction<T> toLongFunction(CheckedToLongFunction<T> function)
CheckedToLongFunction
in a ToLongFunction
.
Example:
map.computeIfAbsent("key", Unchecked.toLongFunction(k -> {
if (k.length() > 10)
throw new Exception("Only short strings allowed");
return 42L;
}));
public static <T> java.util.function.ToLongFunction<T> toLongFunction(CheckedToLongFunction<T> function, java.util.function.Consumer<java.lang.Throwable> handler)
CheckedToLongFunction
in a ToLongFunction
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);
}
));
public static <T> java.util.function.ToDoubleFunction<T> toDoubleFunction(CheckedToDoubleFunction<T> function)
CheckedToDoubleFunction
in a ToDoubleFunction
.
Example:
map.computeIfAbsent("key", Unchecked.toDoubleFunction(k -> {
if (k.length() > 10)
throw new Exception("Only short strings allowed");
return 42.0;
}));
public static <T> java.util.function.ToDoubleFunction<T> toDoubleFunction(CheckedToDoubleFunction<T> function, java.util.function.Consumer<java.lang.Throwable> handler)
CheckedToDoubleFunction
in a ToDoubleFunction
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);
}
));
public static <R> java.util.function.IntFunction<R> intFunction(CheckedIntFunction<R> function)
CheckedIntFunction
in a IntFunction
.
Example:
IntStream.of(1, 2, 3).mapToObj(Unchecked.intFunction(i -> {
if (i < 0)
throw new Exception("Only positive numbers allowed");
return "" + i;
});
public static <R> java.util.function.IntFunction<R> intFunction(CheckedIntFunction<R> function, java.util.function.Consumer<java.lang.Throwable> handler)
CheckedIntFunction
in a IntFunction
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);
}
));
public static java.util.function.IntToLongFunction intToLongFunction(CheckedIntToLongFunction function)
CheckedIntToLongFunction
in a IntToLongFunction
.
Example:
IntStream.of(1, 2, 3).mapToLong(Unchecked.intToLongFunction(i -> {
if (i < 0)
throw new Exception("Only positive numbers allowed");
return (long) i;
});
public static java.util.function.IntToLongFunction intToLongFunction(CheckedIntToLongFunction function, java.util.function.Consumer<java.lang.Throwable> handler)
CheckedIntToLongFunction
in a IntToLongFunction
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);
}
));
public static java.util.function.IntToDoubleFunction intToDoubleFunction(CheckedIntToDoubleFunction function)
CheckedIntToDoubleFunction
in a IntToDoubleFunction
.
Example:
IntStream.of(1, 2, 3).mapToDouble(Unchecked.intToDoubleFunction(i -> {
if (i < 0)
throw new Exception("Only positive numbers allowed");
return (double) i;
});
public static java.util.function.IntToDoubleFunction intToDoubleFunction(CheckedIntToDoubleFunction function, java.util.function.Consumer<java.lang.Throwable> handler)
CheckedIntToDoubleFunction
in a IntToDoubleFunction
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);
}
));
public static <R> java.util.function.LongFunction<R> longFunction(CheckedLongFunction<R> function)
CheckedLongFunction
in a LongFunction
.
Example:
LongStream.of(1L, 2L, 3L).mapToObj(Unchecked.longFunction(l -> {
if (l < 0L)
throw new Exception("Only positive numbers allowed");
return "" + l;
});
public static <R> java.util.function.LongFunction<R> longFunction(CheckedLongFunction<R> function, java.util.function.Consumer<java.lang.Throwable> handler)
CheckedLongFunction
in a LongFunction
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);
}
));
public static java.util.function.LongToIntFunction longToIntFunction(CheckedLongToIntFunction function)
CheckedLongToIntFunction
in a LongToIntFunction
.
Example:
LongStream.of(1L, 2L, 3L).mapToInt(Unchecked.longToIntFunction(l -> {
if (l < 0L)
throw new Exception("Only positive numbers allowed");
return (int) l;
});
public static java.util.function.LongToIntFunction longToIntFunction(CheckedLongToIntFunction function, java.util.function.Consumer<java.lang.Throwable> handler)
CheckedLongToIntFunction
in a LongToIntFunction
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);
}
));
public static java.util.function.LongToDoubleFunction longToDoubleFunction(CheckedLongToDoubleFunction function)
CheckedLongToDoubleFunction
in a LongToDoubleFunction
.
Example:
LongStream.of(1L, 2L, 3L).mapToInt(Unchecked.longToDoubleFunction(l -> {
if (l < 0L)
throw new Exception("Only positive numbers allowed");
return (double) l;
});
public static java.util.function.LongToDoubleFunction longToDoubleFunction(CheckedLongToDoubleFunction function, java.util.function.Consumer<java.lang.Throwable> handler)
CheckedLongToDoubleFunction
in a LongToDoubleFunction
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);
}
));
public static <R> java.util.function.DoubleFunction<R> doubleFunction(CheckedDoubleFunction<R> function)
CheckedDoubleFunction
in a DoubleFunction
.
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;
});
public static <R> java.util.function.DoubleFunction<R> doubleFunction(CheckedDoubleFunction<R> function, java.util.function.Consumer<java.lang.Throwable> handler)
CheckedDoubleFunction
in a DoubleFunction
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);
}
));
public static java.util.function.DoubleToIntFunction doubleToIntFunction(CheckedDoubleToIntFunction function)
CheckedDoubleToIntFunction
in a DoubleToIntFunction
.
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;
});
public static java.util.function.DoubleToIntFunction doubleToIntFunction(CheckedDoubleToIntFunction function, java.util.function.Consumer<java.lang.Throwable> handler)
CheckedDoubleToIntFunction
in a DoubleToIntFunction
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);
}
));
public static java.util.function.DoubleToLongFunction doubleToLongFunction(CheckedDoubleToLongFunction function)
CheckedDoubleToLongFunction
in a DoubleToLongFunction
.
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;
});
public static java.util.function.DoubleToLongFunction doubleToLongFunction(CheckedDoubleToLongFunction function, java.util.function.Consumer<java.lang.Throwable> handler)
CheckedDoubleToLongFunction
in a DoubleToLongFunction
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);
}
));
public static <T> java.util.function.Predicate<T> predicate(CheckedPredicate<T> predicate)
CheckedPredicate
in a Predicate
.
Example:
Stream.of("a", "b", "c").filter(Unchecked.predicate(s -> {
if (s.length() > 10)
throw new Exception("Only short strings allowed");
return true;
}));
public static <T> java.util.function.Predicate<T> predicate(CheckedPredicate<T> function, java.util.function.Consumer<java.lang.Throwable> handler)
CheckedPredicate
in a Predicate
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);
}
));
public static java.util.function.IntPredicate intPredicate(CheckedIntPredicate predicate)
CheckedPredicate
in a IntPredicate
.
Example:
IntStream.of(1, 2, 3).filter(Unchecked.intPredicate(i -> {
if (i < 0)
throw new Exception("Only positive numbers allowed");
return true;
}));
public static java.util.function.IntPredicate intPredicate(CheckedIntPredicate function, java.util.function.Consumer<java.lang.Throwable> handler)
CheckedPredicate
in a IntPredicate
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);
}
));
public static java.util.function.LongPredicate longPredicate(CheckedLongPredicate predicate)
CheckedLongPredicate
in a LongPredicate
.
Example:
LongStream.of(1L, 2L, 3L).filter(Unchecked.longPredicate(l -> {
if (l < 0L)
throw new Exception("Only positive numbers allowed");
return true;
}));
public static java.util.function.LongPredicate longPredicate(CheckedLongPredicate function, java.util.function.Consumer<java.lang.Throwable> handler)
CheckedLongPredicate
in a LongPredicate
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);
}
));
public static java.util.function.DoublePredicate doublePredicate(CheckedDoublePredicate predicate)
CheckedDoublePredicate
in a DoublePredicate
.
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;
}));
public static java.util.function.DoublePredicate doublePredicate(CheckedDoublePredicate function, java.util.function.Consumer<java.lang.Throwable> handler)
CheckedDoublePredicate
in a DoublePredicate
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);
}
));
public static <T> java.util.function.Supplier<T> supplier(CheckedSupplier<T> supplier)
CheckedSupplier
in a Supplier
.
Example:
ResultSet rs = statement.executeQuery();
Stream.generate(Unchecked.supplier(() -> rs.getObject(1)));
public static <T> java.util.function.Supplier<T> supplier(CheckedSupplier<T> supplier, java.util.function.Consumer<java.lang.Throwable> handler)
CheckedSupplier
in a Supplier
with a custom handler for checked exceptions.
Example:
ResultSet rs = statement.executeQuery();
Stream.generate(Unchecked.supplier(
() -> rs.getObject(1),
e -> {
throw new IllegalStateException(e);
}
));
public static java.util.function.IntSupplier intSupplier(CheckedIntSupplier supplier)
CheckedIntSupplier
in a IntSupplier
.
Example:
ResultSet rs = statement.executeQuery();
Stream.generate(Unchecked.intSupplier(() -> rs.getInt(1)));
public static java.util.function.IntSupplier intSupplier(CheckedIntSupplier supplier, java.util.function.Consumer<java.lang.Throwable> handler)
CheckedIntSupplier
in a IntSupplier
with a custom handler for checked exceptions.
Example:
ResultSet rs = statement.executeQuery();
Stream.generate(Unchecked.intSupplier(
() -> rs.getInt(1),
e -> {
throw new IllegalStateException(e);
}
));
public static java.util.function.LongSupplier longSupplier(CheckedLongSupplier supplier)
CheckedLongSupplier
in a LongSupplier
.
Example:
ResultSet rs = statement.executeQuery();
Stream.generate(Unchecked.longSupplier(() -> rs.getLong(1)));
public static java.util.function.LongSupplier longSupplier(CheckedLongSupplier supplier, java.util.function.Consumer<java.lang.Throwable> handler)
CheckedLongSupplier
in a LongSupplier
with a custom handler for checked exceptions.
Example:
ResultSet rs = statement.executeQuery();
Stream.generate(Unchecked.longSupplier(
() -> rs.getLong(1),
e -> {
throw new IllegalStateException(e);
}
));
public static java.util.function.DoubleSupplier doubleSupplier(CheckedDoubleSupplier supplier)
CheckedDoubleSupplier
in a DoubleSupplier
.
Example:
ResultSet rs = statement.executeQuery();
Stream.generate(Unchecked.doubleSupplier(() -> rs.getDouble(1)));
public static java.util.function.DoubleSupplier doubleSupplier(CheckedDoubleSupplier supplier, java.util.function.Consumer<java.lang.Throwable> handler)
CheckedDoubleSupplier
in a DoubleSupplier
with a custom handler for checked exceptions.
Example:
ResultSet rs = statement.executeQuery();
Stream.generate(Unchecked.doubleSupplier(
() -> rs.getDouble(1),
e -> {
throw new IllegalStateException(e);
}
));
public static java.util.function.BooleanSupplier booleanSupplier(CheckedBooleanSupplier supplier)
CheckedBooleanSupplier
in a BooleanSupplier
.
Example:
ResultSet rs = statement.executeQuery();
Stream.generate(Unchecked.booleanSupplier(() -> rs.getBoolean(1)));
public static java.util.function.BooleanSupplier booleanSupplier(CheckedBooleanSupplier supplier, java.util.function.Consumer<java.lang.Throwable> handler)
CheckedBooleanSupplier
in a BooleanSupplier
with a custom handler for checked exceptions.
Example:
ResultSet rs = statement.executeQuery();
Stream.generate(Unchecked.booleanSupplier(
() -> rs.getBoolean(1),
e -> {
throw new IllegalStateException(e);
}
));
public static <T> java.util.function.UnaryOperator<T> unaryOperator(CheckedUnaryOperator<T> operator)
CheckedUnaryOperator
in a UnaryOperator
.
Example:
Stream.of("a", "b", "c").map(Unchecked.unaryOperator(s -> {
if (s.length() > 10)
throw new Exception("Only short strings allowed");
return s;
}));
public static <T> java.util.function.UnaryOperator<T> unaryOperator(CheckedUnaryOperator<T> operator, java.util.function.Consumer<java.lang.Throwable> handler)
CheckedUnaryOperator
in a UnaryOperator
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);
}
));
public static java.util.function.IntUnaryOperator intUnaryOperator(CheckedIntUnaryOperator operator)
CheckedIntUnaryOperator
in a IntUnaryOperator
.
Example:
IntStream.of(1, 2, 3).map(Unchecked.intUnaryOperator(i -> {
if (i < 0)
throw new Exception("Only positive numbers allowed");
return i;
}));
public static java.util.function.IntUnaryOperator intUnaryOperator(CheckedIntUnaryOperator operator, java.util.function.Consumer<java.lang.Throwable> handler)
CheckedIntUnaryOperator
in a IntUnaryOperator
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);
}
));
public static java.util.function.LongUnaryOperator longUnaryOperator(CheckedLongUnaryOperator operator)
CheckedLongUnaryOperator
in a LongUnaryOperator
.
Example:
LongStream.of(1L, 2L, 3L).map(Unchecked.longUnaryOperator(l -> {
if (l < 0L)
throw new Exception("Only positive numbers allowed");
return l;
}));
public static java.util.function.LongUnaryOperator longUnaryOperator(CheckedLongUnaryOperator operator, java.util.function.Consumer<java.lang.Throwable> handler)
CheckedLongUnaryOperator
in a LongUnaryOperator
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);
}
));
public static java.util.function.DoubleUnaryOperator doubleUnaryOperator(CheckedDoubleUnaryOperator operator)
CheckedDoubleUnaryOperator
in a DoubleUnaryOperator
.
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;
}));
public static java.util.function.DoubleUnaryOperator doubleUnaryOperator(CheckedDoubleUnaryOperator operator, java.util.function.Consumer<java.lang.Throwable> handler)
CheckedDoubleUnaryOperator
in a DoubleUnaryOperator
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);
}
));
Copyright © 2018. All rights reserved.