/** * Flattens the execution result to the actual outcome of the execution. If an exception occured, it is throw, * if it returned any result - including null - it is returned. * @return * the actual return value of the operation * @throws Exception * if the execution produced an exception, it is thrown */ public RESULTTYPE flatten() throws Exception { //NOSONAR if (!wasSuccess()) { throw this.exception.get(); } return get(); }
/** * Executes a specified task. If an exception occurs it will be wrapped in a RuntimeException * @param runnable * the task to be executed * @return * the result of the task execution */ public static void runUnchecked(Runnable runnable) { //NOSONAR runProtected(runnable).mapException(Exception.class, UncheckedException::new).get(); }
/** * Executes a specified task, regardless if it throws a checked or unchecked exception. * If an exception occurs it will be caught and wrapped in the execution result. * @param call * the task to be executed * @param <T> * the type of the return value * @return * the result of the task execution */ public static <T> T runUnchecked(Callable<T> call) { return runProtected(call).mapException(Exception.class, UncheckedException::new).get(); }