Example usage for java.util.function Consumer accept

List of usage examples for java.util.function Consumer accept

Introduction

In this page you can find the example usage for java.util.function Consumer accept.

Prototype

void accept(T t);

Source Link

Document

Performs this operation on the given argument.

Usage

From source file:org.pdfsam.ui.io.BrowsablePdfInputField.java

public void apply(SinglePdfSourceTaskParametersBuilder<?> builder, Consumer<String> onError) {
    getTextField().validate();/*from  w ww .  ja  v a 2 s.com*/
    if (getTextField().getValidationState() == ValidationState.VALID) {
        builder.source(new PdfFileSourceAdapter(getTextField().getText()).getPdfFileSource());
    } else {
        onError.accept(DefaultI18nContext.getInstance().i18n("The selected PDF file is invalid"));
    }
}

From source file:com.neatresults.mgnltweaks.app.status.ConfigStatusPresenter.java

private void filterData(NodeIterator iter, Predicate<Node> exists, Consumer<Node> total, Consumer<Node> fails)
        throws RepositoryException {
    while (iter.hasNext()) {
        Node n = iter.nextNode();
        total.accept(n);
        if (!exists.test(n)) {
            fails.accept(n);/*from ww  w.j  ava  2 s  .  co  m*/
        }
    }
}

From source file:com.teradata.benchto.driver.macro.shell.ShellMacroExecutionDriver.java

private void logStream(InputStream inputStream, Consumer<String> logger) throws IOException {
    String line;/*  www. j  av  a 2  s  . com*/
    try (BufferedReader input = new BufferedReader(new InputStreamReader(inputStream))) {
        while ((line = input.readLine()) != null) {
            logger.accept(line);
        }
    }
}

From source file:org.apache.tinkerpop.gremlin.tinkergraph.process.computer.TinkerWorkerPool.java

public void executeMapReduce(final Consumer<MapReduce> worker) {
    for (int i = 0; i < this.numberOfWorkers; i++) {
        this.completionService.submit(() -> {
            final MapReduce mr = this.mapReducePool.take();
            worker.accept(mr);
            this.mapReducePool.offer(mr);
            return null;
        });//from   w ww  . ja  v a 2  s .com
    }
    for (int i = 0; i < this.numberOfWorkers; i++) {
        try {
            this.completionService.take().get();
        } catch (final Exception e) {
            throw new IllegalStateException(e.getMessage(), e);
        }
    }
}

From source file:com.antonjohansson.svncommit.core.utils.Bash.java

private void accept(Consumer<String> onData, InputStream logStream) throws IOException {
    byte[] buffer = new byte[1024];
    logStream.read(buffer);// w w  w  .  j  ava 2s .  c om
    String output = new String(buffer);
    onData.accept(output);
}

From source file:ch.algotrader.event.dispatch.MarketDataSubscriptionRegistry.java

public void invoke(final long securityId, final Consumer<String> consumer) {

    Set<String> strategySet = this.marketDataSubscriptionMap.get(securityId);
    if (strategySet != null && !strategySet.isEmpty()) {
        for (String strategyName : strategySet) {
            consumer.accept(strategyName);
        }/*ww  w.  j  ava 2  s.  c om*/
    }
}

From source file:org.openstreetmap.josm.plugins.PluginHandlerTestIT.java

void testPlugin(Consumer<Layer> consumer, Layer layer, Map<String, Throwable> layerExceptions,
        Collection<PluginInformation> loadedPlugins) {
    try {// ww w .j a  va2s. co m
        consumer.accept(layer);
    } catch (Exception | LinkageError t) {
        Throwable root = ExceptionUtils.getRootCause(t);
        root.printStackTrace();
        layerExceptions.put(findFaultyPlugin(loadedPlugins, root), root);
    }
}

From source file:uk.co.sdev.async.http.ning.ObservableClient.java

public Observable<byte[]> stream(String url, Consumer<Request> requestConsumer) {
    return Observable.create(subscriber -> {
        try {//  w w  w. ja va 2 s  .c o m
            Request request = asyncHttpClient.prepareGet(url).build();
            requestConsumer.accept(request);
            asyncHttpClient.executeRequest(request, new ObservableAsyncHandler(subscriber));
        } catch (Exception e) {
            subscriber.onError(e);
        }
    });
}

From source file:org.apache.tinkerpop.gremlin.tinkergraph.process.computer.TinkerWorkerPool.java

public void executeVertexProgram(final Consumer<VertexProgram> worker) {
    for (int i = 0; i < this.numberOfWorkers; i++) {
        this.completionService.submit(() -> {
            final VertexProgram vp = this.vertexProgramPool.take();
            worker.accept(vp);
            this.vertexProgramPool.offer(vp);
            return null;
        });/*w w  w.j av  a  2s  . co  m*/
    }
    for (int i = 0; i < this.numberOfWorkers; i++) {
        try {
            this.completionService.take().get();
        } catch (final Exception e) {
            throw new IllegalStateException(e.getMessage(), e);
        }
    }
}

From source file:org.apache.tinkerpop.gremlin.AbstractGremlinTest.java

/**
 * Utility method that commits if the graph supports transactions and executes an assertion function before and
 * after the commit.  It assumes that the assertion should be true before and after the commit.
 *//*from www .j a v a2  s.c o  m*/
public void tryCommit(final Graph graph, final Consumer<Graph> assertFunction) {
    assertFunction.accept(graph);
    if (graph.features().graph().supportsTransactions()) {
        graph.tx().commit();
        assertFunction.accept(graph);
    }
}