/*
 * Copyright © 2013-2017, The SeedStack authors <http://seedstack.org>
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

package org.seedstack.shed.exception;

public final class Throwing {
    private Throwing() {
        // no instantiation allowed
    }

    @SuppressWarnings("unchecked")
    private static <X extends Throwable> void throwException(Throwable exception) throws X {
        throw (X) exception;
    }

    @FunctionalInterface
    public interface Consumer<T, X extends Throwable> extends java.util.function.Consumer<T> {

        void apply(T t) throws X;

        @Override
        default void accept(T t) {
            try {
                apply(t);
            } catch (Throwable throwable) {
                Throwing.throwException(throwable);
            }
        }
    }
}

@@ -712,21 +712,24 @@
    void 
-apply
+doAccept
 (T t) th
@@ -828,15 +828,1904 @@
     
-apply(t
+doAccept(t);%0A            %7D catch (Throwable throwable) %7B%0A                Throwing.throwException(throwable);%0A            %7D%0A            throw new IllegalStateException(%22Error in throwing consumer%22);%0A        %7D%0A    %7D%0A%0A    @FunctionalInterface%0A    public interface BiConsumer%3CT, U, X extends Throwable%3E extends java.util.function.BiConsumer%3CT, U%3E %7B%0A%0A        void doAccept(T t, U u) throws X;%0A%0A        @Override%0A        default void accept(T t, U u) %7B%0A            try %7B%0A                doAccept(t, u);%0A            %7D catch (Throwable throwable) %7B%0A                Throwing.throwException(throwable);%0A            %7D%0A            throw new IllegalStateException(%22Error in throwing bi-consumer%22);%0A        %7D%0A    %7D%0A%0A    @FunctionalInterface%0A    public interface Supplier%3CT, X extends Throwable%3E extends java.util.function.Supplier%3CT%3E %7B%0A%0A        T doGet() throws X;%0A%0A        @Override%0A        default T get() %7B%0A            try %7B%0A                return doGet();%0A            %7D catch (Throwable throwable) %7B%0A                Throwing.throwException(throwable);%0A            %7D%0A            throw new IllegalStateException(%22Error in throwing supplier%22);%0A        %7D%0A    %7D%0A%0A    @FunctionalInterface%0A    public interface Function%3CT, R, X extends Throwable%3E extends java.util.function.Function%3CT, R%3E %7B%0A%0A        R doApply(T t) throws X;%0A%0A        @Override%0A        default R apply(T t) %7B%0A            try %7B%0A                return doApply(t);%0A            %7D catch (Throwable throwable) %7B%0A                Throwing.throwException(throwable);%0A            %7D%0A            throw new IllegalStateException(%22Error in throwing function%22);%0A        %7D%0A    %7D%0A%0A    @FunctionalInterface%0A    public interface BiFunction%3CT, U, R, X extends Throwable%3E extends java.util.function.BiFunction%3CT, U, R%3E %7B%0A%0A        R doApply(T t, U u) throws X;%0A%0A        @Override%0A        default R apply(T t, U u) %7B%0A            try %7B%0A                return doApply(t, u
 );%0A 
@@ -2811,32 +2811,32 @@
 ion(throwable);%0A
-
             %7D%0A  
@@ -2825,32 +2825,107 @@
 ;%0A            %7D%0A
+            throw new IllegalStateException(%22Error in throwing function%22);%0A
         %7D%0A    %7D%0A

Add some throwing classes