/** * Creates a callback that will attempt to initialize once. If initialize throws, onInitFailureCleanup is called * before wrapping and throwing a RuntimeException. * @param initialize initialization method. * @param onInitFailureCleanup cleanup to be done in case initialization throws. If this method also throws, it will * propagate up to the caller. * @return the desired Callback object. */ public static <R> Callback<R> singleAttempt(Consumer<R> initialize, BiConsumer<R, Throwable> onInitFailureCleanup) { return new LambdaCallback<>(initialize, onInitFailureCleanup.andThen(FAIL)); }
@Property public void chained( BiConsumer<T, U> first, BiConsumer<? super T, ? super U> second, T firstArg, U secondArg) { first.andThen(second).accept(firstArg, secondArg); } }
@Override public void load(Collection<? extends PdfDocumentDescriptor> toLoad, RequiredPdfData... requires) { LOG.debug(DefaultI18nContext.getInstance().i18n("Loading pdf documents")); BiConsumer<PDDocument, PdfDocumentDescriptor> consumer = Arrays.stream(requires).map(consumers::get) .reduce(STARTER, (r, d) -> r.andThen(d)).andThen(FINISHER); for (PdfDocumentDescriptor current : toLoad) { if (current.hasReferences()) { LOG.trace("Loading {}", current.getFileName()); fxMoveStatusTo(current, LOADING); try (PDDocument document = PDFParser.parse( new BufferedSeekableSource(new FileChannelSeekableSource(current.getFile())), current.getPassword())) { consumer.accept(document, current); } catch (InvalidPasswordException twpe) { fxMoveStatusTo(current, ENCRYPTED); LOG.warn("User password required for '{}'", current.getFileName(), twpe); } catch (Exception e) { LOG.error("An error occured loading the document '{}'", current.getFileName(), e); fxMoveStatusTo(current, WITH_ERRORS); } LOG.info("{} loaded", current.getFileName()); } else { LOG.trace("Skipping invalidated document {}", current.getFileName()); } } LOG.debug(DefaultI18nContext.getInstance().i18n("Documents loaded")); }
private <T, S> BiConsumer<T, S> chainConsumers(final BiConsumer<T, S> currentConsumer, final BiConsumer<T, S> consumer) { if (currentConsumer != null) { return currentConsumer.andThen(consumer); } return consumer; }
@Override public Dispatcher<String> exceptionHandler(BiConsumer<Throwable, RequestContext> handler) { this.exceptionHandler = exceptionHandler.andThen(handler); return this; }
private <T, S> BiConsumer<T, S> chainConsumers(final BiConsumer<T, S> currentConsumer, final BiConsumer<T, S> consumer) { if (currentConsumer != null) { return currentConsumer.andThen(consumer); } return consumer; }
private static <T, U> BiConsumer<T, U> chain(BiConsumer<T, U> first, BiConsumer<T, U> second) { return first.andThen(second); }
public MapFactoryBuilder<A, T> put(String key, Object value) { manipulationChain = manipulationChain.andThen((a, m) -> m.put(key, value)); return this; }
public MapFactoryBuilder<A, T> put(String key, Object value) { manipulationChain = manipulationChain.andThen((a, m) -> m.put(key, value)); return this; }
public MapFactoryBuilder<A, T> allOf(Function<A, Map<String, Object>> otherMap) { manipulationChain = manipulationChain.andThen((a, m) -> m.putAll(otherMap.apply(a))); return this; }
public MapFactoryBuilder<A, T> allOf(Function<A, Map<String, Object>> otherMap) { manipulationChain = manipulationChain.andThen((a, m) -> m.putAll(otherMap.apply(a))); return this; }
public MapFactoryBuilder<A, T> put(String key, Function<A, Object> valueFunction) { manipulationChain = manipulationChain.andThen((a, m) -> m.put(key, valueFunction.apply(a))); return this; }
public MapFactoryBuilder<A, T> put(String key, Function<A, Object> valueFunction) { manipulationChain = manipulationChain.andThen((a, m) -> m.put(key, valueFunction.apply(a))); return this; }
private void persistTraces(final HttpServletRequest request, final HttpServletResponse response) { final BiConsumer<String, String> setAttribute = request::setAttribute; final BiConsumer<String, String> setHeader = response::setHeader; tracer.forEach(setAttribute.andThen(setHeader)); }
/** * Creates a callback that will attempt to initialize once. If initialize throws, onInitFailureCleanup is called * before wrapping and throwing a RuntimeException. * @param initialize initialization method. * @param onInitFailureCleanup cleanup to be done in case initialization throws. If this method also throws, it will * propagate up to the caller. * @return the desired Callback object. */ public static <R> Callback<R> singleAttempt(Consumer<R> initialize, BiConsumer<R, Throwable> onInitFailureCleanup) { return new LambdaCallback<>(initialize, onInitFailureCleanup.andThen(FAIL)); }
public Corpus transform(final BiConsumer<Path, KAFDocument> transformer) { return new Corpus(this.files, this.transformer == null ? transformer : this.transformer.andThen(transformer)); }
@Override protected ContextHandler<SocketChannel> doHandler(BiFunction<? super NettyInbound, ? super NettyOutbound, ? extends Publisher<Void>> handler, MonoSink<NettyContext> sink, boolean secure, SocketAddress providedAddress, ChannelPool pool, Consumer<? super Channel> onSetup) { ContextHandler<SocketChannel> h = ContextHandler.newClientContext(sink, options, loggingHandler, secure, providedAddress, pool, handler != null ? (ch, c, msg) -> { if(onSetup != null){ onSetup.accept(ch); } return HttpClientOperations.bindHttp(ch, handler, c); } : EMPTY); if (handler == null) { h.onPipeline(ACTIVE_CONFIGURATOR.andThen(this)); } else { h.onPipeline(this); } return h; }
urnPathMap.forEach(createFileMetadata(deriv).andThen(persistURN(deriv)));
.andThen((ev, t) -> pushAfterNextFlowStackElement().accept(event))) .onErrorResume(MessagingException.class, t -> {