/** * Convert at {@link BiFunctionWithException} into a {@link BiFunction}. * * @param biFunctionWithException function with exception to convert into a function * @param <A> input type * @param <B> output type * @return {@link BiFunction} which throws all checked exception as an unchecked exception. */ static <A, B, C> BiFunction<A, B, C> unchecked(BiFunctionWithException<A, B, C, ?> biFunctionWithException) { return (A a, B b) -> { try { return biFunctionWithException.apply(a, b); } catch (Throwable t) { ExceptionUtils.rethrow(t); // we need this to appease the compiler :-( return null; } }; } }
BiFunctionWithException.unchecked((Boolean confirmLeadership, Collection<JobGraph> recoveredJobs) -> { if (confirmLeadership) { leaderElectionService.confirmLeaderSessionID(newLeaderSessionID);
default R apply(T t, U u) { try { return applyWithException(t, u); } catch (Throwable e) { ExceptionUtils.rethrow(e); // we have to return a value to please the compiler // but we will never reach the code here return null; } } }
BiFunctionWithException.unchecked((Boolean confirmLeadership, Collection<JobGraph> recoveredJobs) -> { if (confirmLeadership) { leaderElectionService.confirmLeaderSessionID(newLeaderSessionID);
/** * Convert at {@link BiFunctionWithException} into a {@link BiFunction}. * * @param biFunctionWithException function with exception to convert into a function * @param <A> input type * @param <B> output type * @return {@link BiFunction} which throws all checked exception as an unchecked exception. */ static <A, B, C> BiFunction<A, B, C> unchecked(BiFunctionWithException<A, B, C, ?> biFunctionWithException) { return (A a, B b) -> { try { return biFunctionWithException.apply(a, b); } catch (Throwable t) { ExceptionUtils.rethrow(t); // we need this to appease the compiler :-( return null; } }; } }