pivovarit / throwing-function

Checked Exceptions-enabled Java 8+ functional interfaces + adapters

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Missing sneaky static method on ThrowingBinaryOperator

rwperrott opened this issue · comments

ThrowingBiFunctions method
static <T1, T2, R> BiFunction<T1, T2, R> sneaky(ThrowingBiFunction<? super T1, ? super T2, ? extends R, ?> function)
can't be used directly, it'd cause a casting failure, so has to be copied like this in ThrowingBinaryOperator:

    static <T> BinaryOperator<T> sneaky(ThrowingBinaryOperator<T, ?> function) {
        requireNonNull(function);
        return (t1, t2) -> {
            try {
                return function.apply(t1, t2);
            } catch (final Throwable ex) {
                return SneakyThrowUtil.sneakyThrow(ex);
            }
        };
    }

As mentioned in issue 79, my fix is in ThrowingBiFunctions.java in my fork at https://github.com/rwperrott/throwing-function

I'll probably move to using jOOλ, a library of jOOQ, because it covers a lot more than even my fork does for functional interfaces, so I'm closing this issue.

Too bad you did not issue a PR, good luck :)