public static <T>ObjLongConsumerChainer<T> objLongConsumer( final ThrowingObjLongConsumer<T> consumer) { return new ObjLongConsumerChainer<>(consumer); }
@Override public ObjLongConsumer<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> ThrowingObjLongConsumer<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 ThrowingObjLongConsumer<Type1> throwing = getThrowing(); configureFull(throwing); final ObjLongConsumer<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 ObjLongConsumer<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> ThrowingObjLongConsumer<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>ObjLongConsumerChainer<T> objLongConsumer( final ThrowingObjLongConsumer<T> consumer) { return new ObjLongConsumerChainer<>(consumer); }
@Override public ObjLongConsumerChainer<T> orTryWith( final ThrowingObjLongConsumer<T> other) { final ThrowingObjLongConsumer<T> consumer = (t, value) -> { try { throwing.doAccept(t, value); } catch (Error | RuntimeException e) { throw e; } catch (Throwable ignored) { other.doAccept(t, value); } }; return new ObjLongConsumerChainer<>(consumer); }
@Override public ObjLongConsumerChainer<T> orTryWith( final ThrowingObjLongConsumer<T> other) { final ThrowingObjLongConsumer<T> consumer = (t, value) -> { try { throwing.doAccept(t, value); } catch (Error | RuntimeException e) { throw e; } catch (Throwable ignored) { other.doAccept(t, value); } }; return new ObjLongConsumerChainer<>(consumer); }