public static DoubleConsumerChainer doubleConsumer( final ThrowingDoubleConsumer consumer) { return new DoubleConsumerChainer(consumer); }
@Override public DoubleConsumer sneakyThrow() { return value -> { try { throwing.doAccept(value); } catch (Error | RuntimeException e) { throw e; } catch (Throwable throwable) { throw doSneakyThrow(throwable); } }; }
@Override public <E extends RuntimeException> ThrowingDoubleConsumer orThrow( final Class<E> exclass) { return value -> { try { throwing.doAccept(value); } catch (Error | RuntimeException e) { throw e; } catch (Throwable throwable) { throw rethrow(exclass, throwable); } }; }
@Test public void orDoNothingTest() throws Throwable { final ThrowingDoubleConsumer throwing = getThrowing(); configureFull(throwing); final DoubleConsumer chain = getChain(throwing).orDoNothing(); final Callable<Type1> callable = toCallable(chain); assertThat(callable.call()).isSameAs(ret1); assertThat(callable.call()).isSameAs(ret1); verifyUncheckedThrow(callable); verifyErrorThrow(callable); } }
@Override public DoubleConsumer sneakyThrow() { return value -> { try { throwing.doAccept(value); } catch (Error | RuntimeException e) { throw e; } catch (Throwable throwable) { throw doSneakyThrow(throwable); } }; }
@Override public <E extends RuntimeException> ThrowingDoubleConsumer orThrow( final Class<E> exclass) { return value -> { try { throwing.doAccept(value); } catch (Error | RuntimeException e) { throw e; } catch (Throwable throwable) { throw rethrow(exclass, throwable); } }; }
public static DoubleConsumerChainer doubleConsumer( final ThrowingDoubleConsumer consumer) { return new DoubleConsumerChainer(consumer); }
@Override public DoubleConsumerChainer orTryWith( final ThrowingDoubleConsumer other) { final ThrowingDoubleConsumer consumer = value -> { try { throwing.doAccept(value); } catch (Error | RuntimeException e) { throw e; } catch (Throwable ignored) { other.doAccept(value); } }; return new DoubleConsumerChainer(consumer); }
@Override public DoubleConsumerChainer orTryWith( final ThrowingDoubleConsumer other) { final ThrowingDoubleConsumer consumer = value -> { try { throwing.doAccept(value); } catch (Error | RuntimeException e) { throw e; } catch (Throwable ignored) { other.doAccept(value); } }; return new DoubleConsumerChainer(consumer); }