summaryrefslogtreecommitdiff
path: root/core/src/main/java/coffee/liz/ecs/utils/FunctionUtils.java
blob: 25e81f0019d7dc1745bd251c6286f43172f70bf6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package coffee.liz.ecs.utils;


public final class FunctionUtils {
    /**
     * Runs the provided action and wraps failures into a {@link RuntimeException}.
     *
     * @param run
     *            action to execute
     */
    public static <E extends Throwable> void wrapCheckedException(final ThrowableRunnable<E> run) {
        try {
            run.run();
        } catch (final Throwable e) {
            throw new RuntimeException(e);
        }
    }

    @FunctionalInterface
    public interface ThrowableRunnable<E extends Throwable> {
        /**
         * Run.
         */
        void run() throws E;
    }

    private FunctionUtils() { }
}