/** * This method allows a BiConsumer which throws exceptions to be used in places which expects a BiConsumer. * * @param biConsumer instances of the {@code BiConsumerWithExceptions} functional interface * @param <T> the type of the input to the function * @param <U> the type of the input to the function * @param <E> the type of Exception * @return an instance of the {@code BiConsumer} */ public static <T, U, E extends Exception> BiConsumer<T, U> rethrowBiConsumer( BiConsumerWithExceptions<T, U, E> biConsumer) { return (t, u) -> { try { biConsumer.accept(t, u); } catch (Exception exception) { throwAsUnchecked(exception); } }; }
/** * This method allows a BiConsumer which throws exceptions to be used in places which expects a BiConsumer. * * @param biConsumer instances of the {@code BiConsumerWithExceptions} functional interface * @param <T> the type of the input to the function * @param <U> the type of the input to the function * @param <E> the type of Exception * @return an instance of the {@code BiConsumer} */ public static <T, U, E extends Exception> BiConsumer<T, U> rethrowBiConsumer( BiConsumerWithExceptions<T, U, E> biConsumer) { return (t, u) -> { try { biConsumer.accept(t, u); } catch (Exception exception) { throwAsUnchecked(exception); } }; }