Example usage for java.util List forEach

List of usage examples for java.util List forEach

Introduction

In this page you can find the example usage for java.util List forEach.

Prototype

default void forEach(Consumer<? super T> action) 

Source Link

Document

Performs the given action for each element of the Iterable until all elements have been processed or the action throws an exception.

Usage

From source file:io.curly.bloodhound.query.QueryParserTests.java

@NotNull
private static Map<String, String> getMappedKeyValue(List<String> list) {
    Map<String, String> kvMap = new HashMap<>(0);
    list.forEach(item -> {
        String[] kv = item.split(":");
        if (kv.length == 2) {
            kvMap.put(kv[0], kv[1]);//from ww w.  j a  v  a2 s . c o  m
        }
    });
    System.out.println("Mapped Key Value " + kvMap);
    return kvMap;
}

From source file:edu.usu.sdl.openstorefront.core.view.ScheduledReportView.java

public static List<ScheduledReportView> toReportView(List<ScheduledReport> reports) {
    List<ScheduledReportView> views = new ArrayList<>();
    reports.forEach(report -> {
        views.add(toReportView(report));
    });//from   w ww. j  a  va  2s .c  o m
    return views;
}

From source file:com.adeptj.runtime.common.Servlets.java

public static void registerListeners(ServletContext servletContext, List<EventListener> listeners) {
    listeners.forEach(servletContext::addListener);
}

From source file:se.uu.it.cs.recsys.constraint.api.SolverAPI.java

private static void printSolution(List<Map<Integer, Set<se.uu.it.cs.recsys.api.type.Course>>> solutions) {
    solutions.forEach(solution -> {
        LOGGER.info("==> Solution: ");
        solution.entrySet().forEach(period -> {
            LOGGER.info("Period {}, courses:", period.getKey());
            period.getValue().forEach(course -> LOGGER.info("{}", course));
        });// w w w  .  j a  va  2s. c  om
        LOGGER.info("\n");
    });
}

From source file:edu.usu.sdl.openstorefront.core.view.PluginView.java

public static List<PluginView> toView(List<Plugin> plugins) {
    List<PluginView> views = new ArrayList<>();
    plugins.forEach(plugin -> {
        views.add(PluginView.toView(plugin));
    });//from  w w  w .  j  av a 2  s  .  co m
    return views;
}

From source file:com.gazbert.bxbot.repository.impl.MarketConfigRepositoryXmlImpl.java

private static List<MarketConfig> adaptAllInternalToAllExternalConfig(MarketsType internalMarketsConfig) {

    final List<MarketConfig> marketConfigItems = new ArrayList<>();

    final List<MarketType> internalMarketConfigItems = internalMarketsConfig.getMarkets();
    internalMarketConfigItems.forEach((item) -> {

        final MarketConfig marketConfig = new MarketConfig();
        marketConfig.setId(item.getId());
        marketConfig.setLabel(item.getLabel());
        marketConfig.setEnabled(item.isEnabled());
        marketConfig.setBaseCurrency(item.getBaseCurrency());
        marketConfig.setCounterCurrency(item.getCounterCurrency());
        marketConfig.setTradingStrategy(item.getTradingStrategy());

        marketConfigItems.add(marketConfig);
    });/*from  w w w. j a  v a 2 s .com*/

    return marketConfigItems;
}

From source file:ch.sdi.core.TestUtils.java

/**
 * Removes all key/value pairs from environment
 * @param aEnv//w  ww.  j  a  v a  2  s. c  om
 */
public static void removeAllFromEnvironment(ConfigurableEnvironment aEnv) {
    MutablePropertySources propertySources = aEnv.getPropertySources();
    List<PropertySource<?>> toRemove = new ArrayList<PropertySource<?>>();
    propertySources.forEach(p -> toRemove.add(p));
    toRemove.forEach(p -> propertySources.remove(p.getName()));
}

From source file:com.streamsets.pipeline.stage.util.http.HttpStageUtil.java

private static List<Field> convertRecordsToFields(DataParserFactory parserFactory, List<Record> recordList) {
    List<Field> fieldList = new ArrayList<>();
    recordList.forEach(record -> {
        String rawDataHeader = record.getHeader()
                .getAttribute(RestServiceReceiver.RAW_DATA_RECORD_HEADER_ATTR_NAME);
        if (StringUtils.isNotEmpty(rawDataHeader)) {
            String rawData = record.get().getValueAsString();
            try (DataParser parser = parserFactory.getParser("rawData", rawData)) {
                Record parsedRecord = parser.parse();
                while (parsedRecord != null) {
                    fieldList.add(parsedRecord.get());
                    parsedRecord = parser.parse();
                }//from  www .  j  a v a 2  s  .  c  o m
            } catch (Exception e) {
                // If fails to parse data, add raw data from response to envelope record
                fieldList.add(record.get());
                LOG.debug("Failed to parse rawPayloadRecord from Response sink", e);
            }
        } else {
            fieldList.add(record.get());
        }
    });
    return fieldList;
}

From source file:tech.beshu.ror.utils.containers.WireMockContainer.java

public static WireMockContainer create(String... mappings) {
    ImageFromDockerfile dockerfile = new ImageFromDockerfile();
    List<File> mappingFiles = Lists.newArrayList(mappings).stream().map(ContainerUtils::getResourceFile)
            .collect(Collectors.toList());
    mappingFiles.forEach(mappingFile -> dockerfile.withFileFromFile(mappingFile.getName(), mappingFile));
    logger.info("Creating WireMock container ...");
    WireMockContainer container = new WireMockContainer(dockerfile.withDockerfileFromBuilder(builder -> {
        DockerfileBuilder b = builder.from("rodolpheche/wiremock:2.5.1");
        mappingFiles.forEach(mappingFile -> b.copy(mappingFile.getName(), "/home/wiremock/mappings/"));
        b.build();/*from ww w  .ja  v a2s. c o m*/
    }));
    return container.withExposedPorts(WIRE_MOCK_PORT)
            .waitingFor(container.waitStrategy().withStartupTimeout(CONTAINER_STARTUP_TIMEOUT));
}

From source file:io.github.jeddict.jcode.util.PersistenceUtil.java

public static void addClasses(Project project, PersistenceUnit persistenceUnit, List<String> classNames) {
    try {//from w  w w.  j  a  va  2 s. co  m
        PUDataObject pud = ProviderUtil.getPUDataObject(project);
        classNames.forEach((entityClass) -> {
            pud.addClass(persistenceUnit, entityClass, false);
        });
    } catch (InvalidPersistenceXmlException ex) {
        Exceptions.printStackTrace(ex);
    }
}