@@ -0,0 +1,1977 @@
+package by.binarylifestyle.exception.wrapper;%0A%0Aimport java.util.Arrays;%0Aimport java.util.concurrent.Callable;%0Aimport java.util.function.Supplier;%0A%0Apublic class ExceptionToDefaultWrapper %7B%0A    @SafeVarargs%0A    public static %3CT%3E Supplier%3CT%3E fromUnchecked(Supplier%3CT%3E supplier, T defaultValue, Class%3C? extends Exception%3E... exceptionsToWrap) %7B%0A        return CheckedToRuntimeWrapper.from(fromChecked(supplier::get, defaultValue, exceptionsToWrap));%0A    %7D%0A%0A    @SafeVarargs%0A    public static %3CT%3E Callable%3CT%3E fromChecked(Callable%3CT%3E callable, T defaultValue, Class%3C? extends Exception%3E... exceptionsToWrap) %7B%0A        return new ExceptionToDefaultWrapperCallable%3C%3E(callable, defaultValue, exceptionsToWrap);%0A    %7D%0A%0A    private static class ExceptionToDefaultWrapperCallable%3CT%3E implements Callable%3CT%3E %7B%0A        private Class%3C? extends Exception%3E%5B%5D exceptionsToWrap;%0A        private Callable%3CT%3E callable;%0A        private T defaultValue;%0A%0A        @SafeVarargs%0A        @SuppressWarnings(%22unchecked%22)%0A        public ExceptionToDefaultWrapperCallable(Callable%3CT%3E callable, T defaultValue, Class%3C? extends Exception%3E... exceptionsToWrap) %7B%0A            this.callable = callable;%0A            this.defaultValue = defaultValue;%0A            if (exceptionsToWrap.length == 0) %7B%0A                //Default behaviour is to wrap all exceptions to default value%0A                this.exceptionsToWrap = new Class%5B%5D%7BException.class%7D;%0A            %7D else %7B%0A                this.exceptionsToWrap = exceptionsToWrap;%0A            %7D%0A        %7D%0A%0A        @Override%0A        public T call() throws Exception %7B%0A            T result;%0A            try %7B%0A                result = callable.call();%0A            %7D catch (Exception e) %7B%0A                if (Arrays.stream(exceptionsToWrap).anyMatch(exceptionClass -%3E exceptionClass.isInstance(e))) %7B%0A                    result = defaultValue;%0A                %7D else %7B%0A                    throw e;%0A                %7D%0A            %7D%0A            return result;%0A        %7D%0A    %7D%0A%7D%0A

Add ExceptionToDefaultWrapper