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:com.grayfox.server.test.dao.jdbc.UtilJdbcDao.java

public void saveCategories(List<Category> categories) {
    categories.forEach(category -> saveCategory(category));
}

From source file:net.knacht.bootstrap.application.ui.vaadin.views.MainView.java

@Override
public void enter(ViewChangeEvent event) {

    List<Person> persons = service.findAll();

    persons.forEach(
            p -> addComponent(new Label(String.format("ID: %s" + "\t" + "Name: %s", p.getId(), p.getName()))));
}

From source file:com.acmemotors.batch.support.GatewayItemWriter.java

@Override
public void write(List<? extends String> items) throws Exception {
    items.forEach(gateway::send);
}

From source file:bg.elkabel.calculator.service.CoreServiceImpl.java

@Override
public void createAllCores(List<Core> cores) {
    cores.forEach(c -> {
        double weight = calculateWeight(c.getMaterial(), c.getCoreSize());
        c.setWeight(weight);/*  w w  w .j a  va2s.c  om*/

        this.coreRepository.saveAndFlush(c);
    });
}

From source file:net.sourceforge.javydreamercsw.validation.manager.web.component.TestCaseExporter.java

public static Window getTestCaseExporter(List<TestCase> testCases) {
    TreeTable summary = new TreeTable();
    summary.addContainerProperty(TRANSLATOR.translate("general.test.case"), String.class, "");
    summary.addContainerProperty(TRANSLATOR.translate("general.sequence"), String.class, "");
    summary.addContainerProperty(TRANSLATOR.translate("general.text"), String.class, "");
    summary.addContainerProperty(TRANSLATOR.translate("general.notes"), String.class, "");
    summary.addContainerProperty(TRANSLATOR.translate("expected.result"), String.class, "");
    summary.addContainerProperty(TRANSLATOR.translate("expected.result"), String.class, "");
    summary.addContainerProperty(TRANSLATOR.translate("general.result"), String.class, "");
    testCases.forEach(tc -> {
        for (Step step : tc.getStepList()) {
            //Add test case if not there already
            if (!summary.containsId(step.getTestCase().getTestCasePK())) {
                summary.addItem(new Object[] { step.getTestCase().getName(), "", "", "", "", "" },
                        step.getTestCase().getTestCasePK());
            }/*from  w w w  .  ja v  a 2  s  .c  o m*/
            //Add the step
            String stepId = step.getTestCase().getTestCasePK().getId() + "." + step.getStepSequence();
            String text = new String(step.getText(), StandardCharsets.UTF_8), notes = step.getNotes(),
                    expected = new String(step.getExpectedResult(), StandardCharsets.UTF_8);
            summary.addItem(new Object[] { "", "" + step.getStepSequence(), //Sequence
                    text, //Text
                    notes, //Notes
                    expected, //Expected Result
                    "" }, stepId);
            //Put step under the test case
            summary.setParent(stepId, step.getTestCase().getTestCasePK());
            //Add the fields of the test case
            for (DataEntry de : step.getDataEntryList()) {
                String fieldId = step.getTestCase().getTestCasePK() + "." + step.getStepSequence() + ""
                        + (summary.getChildren(stepId) == null ? 0 : summary.getChildren(stepId).size());
                summary.addItem(new Object[] { "", "", //Sequence
                        "", //Text
                        "", //Notes
                        "", //Expected Result
                        de.getEntryName() }, //Field
                        fieldId);
                summary.setParent(fieldId, stepId);
                //Mark test case as a leaf
                summary.setChildrenAllowed(fieldId, false);
            }
        }
    });
    summary.setSizeFull();
    return getExportWindow(summary, null, -1);
}

From source file:com.github.viktornar.service.repository.RepositoryDao.java

@Override
public List<Atlas> getAllAtlases() {
    List<Atlas> atlases = atlasDao.getAll();

    atlases.forEach((atlas) -> {
        Extent extent = extentDao.getById(atlas.getExtentId());
        atlas.setExtent(extent);//  ww w.  j a v a  2  s.  c o m
    });

    return atlases;
}

From source file:com.sample.ecommerce.service.TermService.java

public <S extends Term> List<Term> save(List<? extends Term> itrbl) throws DataStoreException {
    itrbl.forEach(term -> {
        try {//ww w. j a  va 2 s  . c  o m
            dataStore.create(term);
        } catch (DataStoreException ex) {
            LOGGER.error("Unable to crete term", ex);
        }
    });
    return null;
}

From source file:io.engineblock.util.StrInterpolater.java

protected StrInterpolater(List<Map<String, String>> maps) {
    maps.forEach(multimap::add);
}

From source file:com.netflix.spinnaker.orca.mine.pipeline.CanaryPipelineClusterExtractor.java

@Override
public void updateStageClusters(Map stage, List<Map> replacements) {
    List<Map> clusterPairs = (List<Map>) stage.get("clusterPairs");
    clusterPairs.forEach(pair -> {
        pair.put("baseline", replacements.remove(0));
        pair.put("canary", replacements.remove(0));
    });//from   w  w  w.j a  v  a  2  s .co m
}

From source file:io.spring.initializr.metadata.SingleSelectCapability.java

@Override
public void merge(List<DefaultMetadataElement> otherContent) {
    otherContent.forEach(it -> {
        if (get(it.getId()) == null) {
            content.add(it);//from   ww  w  .j a v a  2 s  . c  o  m
        }
    });
}