/** * This method allows a Supplier which throws exceptions to be used in places which expects a Supplier. * * @param <T> Any Object. * @param <E> Any Exception. * @param function Function to apply for given arguments. * @return Supplier of the results. */ public static <T, E extends Exception> Supplier<T> rethrowSupplier(SupplierWithExceptions<T, E> function) { return () -> { try { return function.get(); } catch (Exception exception) { throwAsUnchecked(exception); return null; } }; }
/** * This method allows a Supplier which throws exceptions to be used in places which expects a Supplier. * * @param <T> Any Object. * @param <E> Any Exception. * @param function Function to apply for given arguments. * @return Supplier of the results. */ public static <T, E extends Exception> Supplier<T> rethrowSupplier(SupplierWithExceptions<T, E> function) { return () -> { try { return function.get(); } catch (Exception exception) { throwAsUnchecked(exception); return null; } }; }