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:me.Wundero.Ray.variables.Variables.java

/**
 * Register a new variable wrapper//  w w w.  j  a  v  a 2 s  .co  m
 */
public boolean registerWrapper(String key, Consumer<Text> c, int useless) {
    return registerWrapper(key, (va, t) -> c.accept(t), useless);
}

From source file:org.primeframework.mvc.test.RequestResult.java

/**
 * If the test is true, apply the consumer. Example:
 * <pre>/*from  w  w w . j a  va 2 s .  co  m*/
 *   .ifTrue(foo.isBar(), (requestResult) -> requestResult.assertBodyContains("bar"))
 * </pre>
 *
 * @param test
 * @param consumer
 * @return
 */
public RequestResult ifTrue(boolean test, Consumer<RequestResult> consumer) {
    if (test) {
        consumer.accept(this);
    }
    return this;
}

From source file:org.primeframework.mvc.test.RequestResult.java

/**
 * If the test is false, apply the consumer.
 * <p>/*w  ww.  j ava 2  s  .c  om*/
 * <pre>
 *   .ifFalse(foo.isBar(), (requestResult) -> requestResult.assertBodyDoesNotContain("bar"))
 * </pre>
 *
 * @param test
 * @param consumer
 * @return
 */
public RequestResult ifFalse(boolean test, Consumer<RequestResult> consumer) {
    if (!test) {
        consumer.accept(this);
    }
    return this;
}

From source file:com.qwazr.server.ServletContextBuilder.java

ServletContextBuilder addServlet(final ServletInfo servletInfo, final Consumer<ServletInfo> servletInfoHook) {
    if (servletInfoHook != null)
        servletInfoHook.accept(servletInfo);
    return addServlet(servletInfo);
}

From source file:dk.dma.ais.reader.AisReader.java

protected void distribute(AisPacket packet) {
    linesRead.incrementAndGet();// ww  w  . j a  v a  2  s .com

    if (transformer != null) { // tag the packet with the source if non-null
        packet = transformer.transform(packet);
    }

    for (Consumer<? super AisPacket> packetHandler : packetHandlers) {
        packetHandler.accept(packet);
    }

    // Distribute AIS message
    if (handlers.size() > 0) {
        AisMessage message = null;
        // Parse AIS message
        try {
            message = packet.getAisMessage();
        } catch (AisMessageException me) {
            LOG.info("AIS message exception: " + me.getMessage() + " vdm: "
                    + packet.getVdm().getOrgLinesJoined());
        } catch (SixbitException se) {
            LOG.info("Sixbit error: " + se.getMessage() + " vdm: " + packet.getVdm().getOrgLinesJoined());
        }
        if (message != null) { // Distribute message
            for (Consumer<AisMessage> aisHandler : handlers) {
                aisHandler.accept(message);
            }
        }
    }
}

From source file:com.ucu.seguridad.views.AbstractFxmlView.java

/**
 * Does not initialize the view. Only registers the Consumer and waits until the the view is going to be created / the
 * method FXMLView#getView or FXMLView#getViewAsync invoked.
 *
 * @param presenterConsumer listener for the presenter construction
 *///  ww  w  . j a  v  a 2  s. c o  m
public void getPresenter(Consumer<Object> presenterConsumer) {

    this.presenterProperty
            .addListener((ObservableValue<? extends Object> o, Object oldValue, Object newValue) -> {
                presenterConsumer.accept(newValue);
            });
}

From source file:com.byteatebit.nbserver.task.ReadDelimitedMessageTask.java

public void readMessages(IChannelSelectorRegistrar channelSelectorRegistrar, Consumer<List<String>> callback,
        Consumer<Exception> exceptionHandler) {
    try {//from   ww  w.  ja  va2s  . co m
        channelSelectorRegistrar.register(SelectionKey.OP_READ,
                (selectionKey -> read(selectionKey, callback, exceptionHandler)),
                (selectionKey, ops) -> exceptionHandler.accept(new TimeoutException("read timed out")));
    } catch (Exception e) {
        exceptionHandler.accept(e);
    }
}

From source file:org.onlab.nio.service.IOLoopMessaging.java

protected void dispatchLocally(DefaultMessage message) {
    String type = message.type();
    if (REPLY_MESSAGE_TYPE.equals(type)) {
        try {//  w ww .  jav a2s.  co m
            CompletableFuture<byte[]> futureResponse = responseFutures.getIfPresent(message.id());
            if (futureResponse != null) {
                futureResponse.complete(message.payload());
            } else {
                log.warn("Received a reply for message id:[{}]. " + " from {}. But was unable to locate the"
                        + " request handle", message.id(), message.sender());
            }
        } finally {
            responseFutures.invalidate(message.id());
        }
        return;
    }
    Consumer<DefaultMessage> handler = handlers.get(type);
    if (handler != null) {
        handler.accept(message);
    } else {
        log.debug("No handler registered for {}", type);
    }
}

From source file:be.error.rpi.config.RunConfig.java

public synchronized void doWithLucidControl(Integer device, Consumer<LucidControlAO4> consumer) {
    LucidControlAO4 lucidControlAO4 = lucidControlMap.get(device);
    synchronized (lucidControlAO4) {
        try {//from   w w  w  .ja va2 s. c  o m
            consumer.accept(lucidControlAO4);
        } catch (Exception exception) {
            logger.error("Lucid control had IO error, trying to recover", exception.getCause());
            reInitLucidControl(lucidControlAO4);
            doWithLucidControl(device, consumer);
        }
    }
}

From source file:org.opensingular.flow.core.SingularFlowConfigurationBean.java

/**
 * Notifica os listeners registrados sobre um evento.
 * //from  w w w .  ja v  a2  s  . c om
 * @param operation
 */
public void notifyListeners(Consumer<ProcessNotifier> operation) {
    for (ProcessNotifier n : notifiers) {
        operation.accept(n);
    }
}