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:at.gridtec.lambda4j.function.tri.TriShortFunction.java

/**
 * Returns a composed {@link TriShortConsumer} 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 TriShortConsumer} 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  ww. ja  v  a 2  s  . c om
@Nonnull
default TriShortConsumer consume(@Nonnull final Consumer<? super R> consumer) {
    Objects.requireNonNull(consumer);
    return (value1, value2, value3) -> consumer.accept(apply(value1, value2, value3));
}

From source file:at.gridtec.lambda4j.function.tri.TriDoubleFunction.java

/**
 * Returns a composed {@link TriDoubleConsumer} 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 TriDoubleConsumer} 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  ww .j a  v a  2 s  . c  o m
@Nonnull
default TriDoubleConsumer consume(@Nonnull final Consumer<? super R> consumer) {
    Objects.requireNonNull(consumer);
    return (value1, value2, value3) -> consumer.accept(apply(value1, value2, value3));
}

From source file:org.drools.workbench.screens.dtablexls.backend.server.DecisionTableXLSServiceImplTest.java

private DecisionTableXLSServiceImpl getServiceWithValidationOverride(Consumer<File> validationOverride) {
    return new DecisionTableXLSServiceImpl(ioService, copyService, deleteService, renameService,
            resourceOpenedEvent, conversionService, genericValidator, commentedOptionFactory,
            authenticationService) {//  w w  w .ja  va 2  s . c  om
        @Override
        void validate(final File tempFile) {
            if (validationOverride != null) {
                validationOverride.accept(tempFile);
            } else {
                super.validate(tempFile);
            }
        }
    };
}

From source file:org.openecomp.sdc.be.components.impl.CommonImportManager.java

protected void setPropertiesMap(Map<String, Object> toscaJson,
        Consumer<Map<String, PropertyDefinition>> consumer) {
    final List<PropertyDefinition> properties = getProperties(toscaJson);
    if (properties != null) {
        Map<String, PropertyDefinition> collect = properties.stream()
                .collect(Collectors.toMap(e -> e.getName(), e -> e));
        consumer.accept(collect);
    }/* w  ww.  j  av  a 2 s. com*/

}

From source file:com.idrene.emefana.repositories.RepositoriesTest.java

void updateProvidersLambda(List<Provider> providers, Predicate<Provider> predicate,
        Consumer<Provider> setValues) {
    assertNotNull(providers);// ww w. j  a v  a2  s.  c o  m
    assertTrue(providers.size() > 1);
    if (providers.stream().anyMatch(p -> predicate.test(p))) {
        providers.forEach(p -> setValues.accept(p));
        List<Provider> savedPvrs = providerRepository.save(providers);
        assertFalse(savedPvrs.stream().allMatch(predicate));
    }
}

From source file:it.polimi.diceH2020.SPACE4CloudWS.core.DataProcessor.java

private long calculateMetric(@NonNull List<SolutionPerJob> spjList,
        BiConsumer<SolutionPerJob, Double> resultSaver, Consumer<SolutionPerJob> ifEmpty) {
    //to support also parallel stream.
    AtomicLong executionTime = new AtomicLong();

    spjList.forEach(spj -> {//from   w  w  w . ja  v  a  2s  . co m
        Pair<Optional<Double>, Long> result = simulateClass(spj);
        executionTime.addAndGet(result.getRight());
        Optional<Double> optionalValue = result.getLeft();
        if (optionalValue.isPresent())
            resultSaver.accept(spj, optionalValue.get());
        else
            ifEmpty.accept(spj);
    });

    return executionTime.get();
}

From source file:com.ethlo.geodata.importer.GeonamesBoundaryImporter.java

@Override
public long processFile(Consumer<Map<String, String>> sink) throws IOException {
    long count = 0;
    try (final BufferedReader reader = IoUtils.getBufferedReader(boundaryFile)) {
        String line = reader.readLine(); // skip first line

        while ((line = reader.readLine()) != null) {
            if (StringUtils.isNotBlank(line)) {
                final String[] fields = line.split("\t");
                if (fields.length == 2) {
                    try {
                        final Map<String, String> entry = parsePoints(fields);
                        sink.accept(entry);
                    } catch (ParseException exc) {
                        logger.warn("Cannot parse geometry for location {}: {}", fields[0], exc.getMessage());
                    }//from  w  w w  .  j a va  2  s. co  m
                } else if (logger.isWarnEnabled()) {
                    logger.warn("Unexpected field count for {}", StringUtils.abbreviate(line, 100));
                }
            }

            count++;
        }
    }
    return count;
}

From source file:de.metas.ui.web.vaadin.window.WindowPresenter.java

private final void updateModel(final Consumer<WindowModel> consumer) {
    final WindowModel model = getModel();
    logger.trace("Updating the model {} using {}", model, consumer);
    try {/*from   ww  w. j av  a2  s  .c o m*/
        consumer.accept(model);
        return;
    } catch (final Exception modelException) {
        handleModelException(modelException);
        return;
    }
}

From source file:org.geoserver.opensearch.rest.AbstractOpenSearchController.java

protected Feature queryCollection(String collectionName, Consumer<Query> queryDecorator) throws IOException {
    Query query = new Query();
    query.setFilter(FF.equal(FF.property("name"), FF.literal(collectionName), true));
    queryDecorator.accept(query);
    FeatureCollection<FeatureType, Feature> fc = queryCollections(query);
    Feature feature = DataUtilities.first(fc);
    if (feature == null) {
        throw new ResourceNotFoundException("Could not find a collection named '" + collectionName + "'");
    }/* w ww . j av  a  2s .  co  m*/

    return feature;
}

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

/**
 * Returns a composed {@link ObjBiBooleanConsumer} 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 ObjBiBooleanConsumer} 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  .j  a v  a  2s.co  m*/
@Nonnull
default ObjBiBooleanConsumer<T> consume(@Nonnull final Consumer<? super R> consumer) {
    Objects.requireNonNull(consumer);
    return (t, value1, value2) -> consumer.accept(apply(t, value1, value2));
}