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.failearly.dataz.template.generator.support.LimitedGeneratorDecoratorTest.java

private static void consumeAllValues(Generator<String> generator, Consumer<Generator<String>> consumer) {
    //noinspection unused
    for (String ignored : generator) {
        generator.next();//  w w w.j ava2  s  . c  o  m
        consumer.accept(generator);
    }
}

From source file:at.gridtec.lambda4j.consumer.bi.BiConsumer2.java

/**
 * Creates a {@link BiConsumer2} which uses the {@code first} parameter of this one as argument for the given {@link
 * Consumer}.//from   ww w .  j a v a2 s. c om
 *
 * @param <T> The type of the first argument to the consumer
 * @param <U> The type of the second argument to the consumer
 * @param consumer The consumer which accepts the {@code first} parameter of this one
 * @return Creates a {@code BiConsumer2} which uses the {@code first} parameter of this one as argument for the
 * given {@code Consumer}.
 * @throws NullPointerException If given argument is {@code null}
 */
@Nonnull
static <T, U> BiConsumer2<T, U> onlyFirst(@Nonnull final Consumer<? super T> consumer) {
    Objects.requireNonNull(consumer);
    return (t, u) -> consumer.accept(t);
}

From source file:at.gridtec.lambda4j.consumer.bi.BiConsumer2.java

/**
 * Creates a {@link BiConsumer2} which uses the {@code second} parameter of this one as argument for the given
 * {@link Consumer}.//from ww  w.ja va 2 s. c  o m
 *
 * @param <T> The type of the first argument to the consumer
 * @param <U> The type of the second argument to the consumer
 * @param consumer The consumer which accepts the {@code second} parameter of this one
 * @return Creates a {@code BiConsumer2} which uses the {@code second} parameter of this one as argument for the
 * given {@code Consumer}.
 * @throws NullPointerException If given argument is {@code null}
 */
@Nonnull
static <T, U> BiConsumer2<T, U> onlySecond(@Nonnull final Consumer<? super U> consumer) {
    Objects.requireNonNull(consumer);
    return (t, u) -> consumer.accept(u);
}

From source file:io.syndesis.rest.v1.state.ClientSideStateProperties.java

private static <T> T value(final T given, final Consumer<T> setter, final Supplier<T> generator) {
    if (given != null && !String.valueOf(given).trim().isEmpty()) {
        return given;
    }/*w w  w  . ja va2s  .  c o  m*/

    final T newValue = generator.get();

    setter.accept(newValue);

    return newValue;
}

From source file:it.unibo.alchemist.test.TestInSimulator.java

private static <T> Consumer<Node<T>> checkProtelisProgramValue(final Consumer<Object> check) {
    return n -> n.forEach(r -> {
        r.getActions().parallelStream().filter(a -> a instanceof RunProtelisProgram).forEach(a -> {
            check.accept(n.getConcentration((RunProtelisProgram) a));
        });/*w w w  .ja v a2s  .c  o  m*/
    });
}

From source file:com.epam.jdi.uitests.web.selenium.elements.pageobjects.annotations.WebAnnotationsUtil.java

public static void fillLocator(FindBy value, Consumer<By> action) {
    By by = findByToBy(value);/* ww w .  j  av  a  2  s.  co m*/
    if (by != null)
        action.accept(by);
}

From source file:enumj.Reversible.java

/**
 * Applies a {@code Enumerator.peek(Consumer)} operation
 * upon {@code source}, in reverse if necessary.
 *
 * @param <E> type of enumerated elements.
 * @param source {@link Enumerator} to apply the operation on.
 * @param action {@link Consumer} to apply.
 * @param reversed true if the operation is applied in reverse,
 * false otherwise.//from w w w  .j av  a2  s .  com
 * @return picked {@code Enumerator}.
 */
public static <E> Enumerator<E> peek(Enumerator<E> source, Consumer<? super E> action, boolean reversed) {
    Checks.ensureNonEnumerating(source);
    Checks.ensureNotNull(action, Messages.NULL_ENUMERATOR_CONSUMER);
    final Function<E, E> actionMapper = e -> {
        action.accept(e);
        return e;
    };
    if (reversed) {
        final PipeEnumerator pipe = (PipeEnumerator) source;
        return pipe.reversedMap(actionMapper);
    }
    return source.map(actionMapper);
}

From source file:com.kotcrab.vis.editor.util.FileUtils.java

public static void streamDirectoriesRecursively(FileHandle folder, Consumer<FileHandle> consumer) {
    if (folder.isDirectory() == false)
        throw new IllegalStateException("File must be directory!");

    consumer.accept(folder);
    for (FileHandle file : folder.list()) {
        if (file.isDirectory()) {
            streamDirectoriesRecursively(file, consumer);
        }//from  www . java2 s .c om
    }
}

From source file:com.spotify.hamcrest.jackson.IsJsonObject.java

private static void describeKey(String key, Description mismatchDescription,
        Consumer<Description> innerAction) {
    mismatchDescription.appendText("  ").appendText(jsonEscapeString(key)).appendText(": ");

    final Description innerDescription = new StringDescription();
    innerAction.accept(innerDescription);
    DescriptionUtils.indentDescription(mismatchDescription, innerDescription);
}

From source file:com.kotcrab.vis.editor.util.FileUtils.java

public static void streamRecursively(FileHandle folder, Consumer<FileHandle> consumer) {
    if (folder.isDirectory() == false)
        throw new IllegalStateException("Folder must be directory!");

    consumer.accept(folder);
    for (FileHandle file : folder.list()) {
        consumer.accept(file);//from   ww w. ja v a  2s  .c  om

        if (file.isDirectory()) {
            streamRecursively(file, consumer);
        }
    }
}