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.elasticsoftware.elasticactors.rabbitmq.cpt.RabbitMQMessagingService.java

private void propagateChannelEvent(final Channel channel, final Consumer<ChannelListener> channelEvent,
        final String channelEventName) {
    final Set<ChannelListener> listeners = this.channelListenerRegistry.get(channel);
    if (listeners != null) {
        for (ChannelListener listener : listeners) {
            try {
                channelEvent.accept(listener);
            } catch (Exception e) {
                logger.error(format("Exception while calling [%s] on ChannelListener [%s]", channelEventName,
                        listener.toString()), e);
            }//from www .ja va 2  s  .  c  om
        }
    }
}

From source file:org.brickhouse.impl.MemoryTable.java

@Override
public void readAll(Filter filter, Consumer<HMap> consumer, boolean fillDii) {
    long start = System.nanoTime();
    int count = 0;
    int included = 0;

    try {/*  www  . j  a v  a2 s  . c  o  m*/
        for (HMap row : data.values()) {
            count++;
            if (filter.include(row, pather)) {
                if (fillDii)
                    fillDii(row);
                consumer.accept(new HMap(row));
                included++;
            }
        }
    } catch (CancelReadException e) {
        // no op
    }

    if (stats)
        delegate.saveStats(filter.toString(), count, included, fillDii, System.nanoTime() - start,
                System.currentTimeMillis());
}

From source file:net.dv8tion.jda.entities.impl.PrivateChannelImpl.java

@Override
public void sendFileAsync(File file, Message message, Consumer<Message> callback) {
    Thread thread = new Thread(() -> {
        Message messageReturn;//from  w ww  .  java  2 s .  c  o m
        try {
            messageReturn = sendFile(file, message);
        } catch (RateLimitedException e) {
            JDAImpl.LOG.warn("Got ratelimited when trying to upload file. Providing null to callback.");
            messageReturn = null;
        }

        if (callback != null)
            callback.accept(messageReturn);
    });
    thread.setName("PrivateChannelImpl SendFileAsync Channel: " + id);
    thread.setDaemon(true);
    thread.start();
}

From source file:com.ejisto.core.classloading.ClassTransformerImpl.java

byte[] addMissingProperties(byte[] original, String className, List<MockedField> fields,
        Consumer<CtClass> consumer) throws CannotCompileException, NotFoundException, IOException {
    CtClass clazz = null;/*w  w w  . j a  va  2s.  co m*/
    try {
        if (original != null) {
            clazz = getClassPool().makeClass(new ByteArrayInputStream(original));
        } else {
            clazz = load(className);
        }
        if (addMissingProperties(clazz, fields)) {
            clazz.rebuildClassFile();
            consumer.accept(clazz);
            return clazz.toBytecode();
        }
        return original;
    } finally {
        if (clazz != null) {
            clazz.detach();
        }
    }
}

From source file:at.gridtec.lambda4j.function.tri.obj.BiObjBooleanFunction.java

/**
 * Returns a composed {@link BiObjBooleanConsumer} that fist applies this function to its input, and then consumes
 * the result using the given {@link Consumer}. If evaluation of either operation throws an exception, it is relayed
 * to the caller of the composed operation.
 *
 * @param consumer The operation which consumes the result from this operation
 * @return A composed {@code BiObjBooleanConsumer} that first applies this function to its input, and then consumes
 * the result using the given {@code Consumer}.
 * @throws NullPointerException If given argument is {@code null}
 *///from  w w w.jav a 2 s .co m
@Nonnull
default BiObjBooleanConsumer<T, U> consume(@Nonnull final Consumer<? super R> consumer) {
    Objects.requireNonNull(consumer);
    return (t, u, value) -> consumer.accept(apply(t, u, value));
}

From source file:org.cloudfoundry.identity.uaa.integration.util.IntegrationTestUtils.java

public static IdentityZone createZoneOrUpdateSubdomain(RestTemplate client, String url, String id,
        String subdomain, Consumer<IdentityZoneConfiguration> configureZone) {

    ResponseEntity<String> zoneGet = client.getForEntity(url + "/identity-zones/{id}", String.class, id);
    if (zoneGet.getStatusCode() == HttpStatus.OK) {
        IdentityZone existing = JsonUtils.readValue(zoneGet.getBody(), IdentityZone.class);
        existing.setSubdomain(subdomain);
        client.put(url + "/identity-zones/{id}", existing, id);
        return existing;
    }/*from   w w w  . ja v  a  2s .  c o m*/
    IdentityZone identityZone = fixtureIdentityZone(id, subdomain, new IdentityZoneConfiguration());
    configureZone.accept(identityZone.getConfig());

    ResponseEntity<IdentityZone> zone = client.postForEntity(url + "/identity-zones", identityZone,
            IdentityZone.class);
    return zone.getBody();
}

From source file:at.gridtec.lambda4j.function.tri.obj.BiObjByteFunction.java

/**
 * Returns a composed {@link BiObjByteConsumer} that fist applies this function to its input, and then consumes the
 * result using the given {@link Consumer}. If evaluation of either operation throws an exception, it is relayed to
 * the caller of the composed operation.
 *
 * @param consumer The operation which consumes the result from this operation
 * @return A composed {@code BiObjByteConsumer} that first applies this function to its input, and then consumes the
 * result using the given {@code Consumer}.
 * @throws NullPointerException If given argument is {@code null}
 *///  ww w . jav  a 2  s  .  c o m
@Nonnull
default BiObjByteConsumer<T, U> consume(@Nonnull final Consumer<? super R> consumer) {
    Objects.requireNonNull(consumer);
    return (t, u, value) -> consumer.accept(apply(t, u, value));
}

From source file:at.gridtec.lambda4j.function.tri.obj.BiObjCharFunction.java

/**
 * Returns a composed {@link BiObjCharConsumer} that fist applies this function to its input, and then consumes the
 * result using the given {@link Consumer}. If evaluation of either operation throws an exception, it is relayed to
 * the caller of the composed operation.
 *
 * @param consumer The operation which consumes the result from this operation
 * @return A composed {@code BiObjCharConsumer} that first applies this function to its input, and then consumes the
 * result using the given {@code Consumer}.
 * @throws NullPointerException If given argument is {@code null}
 *///from  www  . ja v  a2 s  .com
@Nonnull
default BiObjCharConsumer<T, U> consume(@Nonnull final Consumer<? super R> consumer) {
    Objects.requireNonNull(consumer);
    return (t, u, value) -> consumer.accept(apply(t, u, value));
}

From source file:at.gridtec.lambda4j.function.tri.obj.BiObjFloatFunction.java

/**
 * Returns a composed {@link BiObjFloatConsumer} that fist applies this function to its input, and then consumes the
 * result using the given {@link Consumer}. If evaluation of either operation throws an exception, it is relayed to
 * the caller of the composed operation.
 *
 * @param consumer The operation which consumes the result from this operation
 * @return A composed {@code BiObjFloatConsumer} that first applies this function to its input, and then consumes
 * the result using the given {@code Consumer}.
 * @throws NullPointerException If given argument is {@code null}
 *///w  w w.  j  ava  2s  . c  o m
@Nonnull
default BiObjFloatConsumer<T, U> consume(@Nonnull final Consumer<? super R> consumer) {
    Objects.requireNonNull(consumer);
    return (t, u, value) -> consumer.accept(apply(t, u, value));
}

From source file:at.gridtec.lambda4j.function.tri.obj.BiObjIntFunction.java

/**
 * Returns a composed {@link BiObjIntConsumer} that fist applies this function to its input, and then consumes the
 * result using the given {@link Consumer}. If evaluation of either operation throws an exception, it is relayed to
 * the caller of the composed operation.
 *
 * @param consumer The operation which consumes the result from this operation
 * @return A composed {@code BiObjIntConsumer} that first applies this function to its input, and then consumes the
 * result using the given {@code Consumer}.
 * @throws NullPointerException If given argument is {@code null}
 *///w  w  w. j av  a  2  s  .c  o m
@Nonnull
default BiObjIntConsumer<T, U> consume(@Nonnull final Consumer<? super R> consumer) {
    Objects.requireNonNull(consumer);
    return (t, u, value) -> consumer.accept(apply(t, u, value));
}