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