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:fi.helsinki.opintoni.security.authorization.PermissionChecker.java

public void verifyPermission(Long userId, List<Long> entityIds, Class<? extends Ownership> entityClass) {
    List<? extends Ownership> entities = commonRepository.find(entityClass, entityIds);
    entities.forEach(entity -> verifyOwner(userId, entity));
}

From source file:com.yqboots.security.web.support.RoleGroupsHtmlOptionsResolver.java

/**
 * {@inheritDoc}/*  w ww.  j  ava 2s.  c o  m*/
 */
@Override
public List<HtmlOption> getHtmlOptions(final String name, final String... attributes) {
    List<HtmlOption> results = new ArrayList<>();

    if (ArrayUtils.isNotEmpty(attributes) && attributes[0] != null) {
        // attributes[0] is path
        List<Group> groups = roleManager.findRoleGroups(attributes[0]);
        groups.forEach(new GroupToHtmlOptionConsumer(name, results));
    }

    return results;
}

From source file:com.yqboots.security.web.support.UserGroupsHtmlOptionsResolver.java

/**
 * {@inheritDoc}// ww w . ja  va  2s .  co  m
 */
@Override
public List<HtmlOption> getHtmlOptions(final String name, final String... attributes) {
    List<HtmlOption> results = new ArrayList<>();

    if (ArrayUtils.isNotEmpty(attributes) && attributes[0] != null) {
        // attributes[0] is username
        List<Group> groups = userManager.findUserGroups(attributes[0]);
        groups.forEach(new GroupToHtmlOptionConsumer(name, results));
    }

    return results;
}

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

@Override
public void merge(List<DependencyGroup> otherContent) {
    otherContent.forEach(group -> {
        if (content.stream().noneMatch(it -> group.getName() != null && group.getName().equals(it.getName()))) {
            content.add(group);//from w w  w  .j  a va 2 s .  co  m
        }
    });
    index();
}

From source file:repository.LieuTest.java

@Test
public void insererLieu() {
    repository.save(new Lieu(1000, 1000));
    repository.save(new Lieu(1000, 1001));
    List<Lieu> allLieuWithLongitudeForTest = repository.findByLongitude(1000);
    allLieuWithLongitudeForTest.forEach(lieu -> System.out.println(lieu.toString()));
    Integer nbrLieuTest = allLieuWithLongitudeForTest.size();
    assertEquals(String.format("2 lieux auraient d tre cr au lieu de %s.", nbrLieuTest), 2,
            nbrLieuTest);//from   w w w . j a  v  a  2s  .co  m
}

From source file:de.kaiserpfalzEdv.office.commons.i18n.MessageBuilder.java

@SuppressWarnings("unchecked")
public MessageBuilder withData(@NotNull final List<? extends Serializable> data) {
    data.forEach(d -> {
        this.data.add(new MessageDetailDataImpl<>(d));
    });/*from   w  w  w  .j  av a2  s.  com*/

    return this;
}

From source file:io.pivio.dependencies.MavenParentPomDependencyReader.java

List<Dependency> removeDuplicates(List<Dependency> dependencies) {
    List<Dependency> clean = new ArrayList<>();
    dependencies.forEach(dependency -> {
        if (!clean.contains(dependency)) {
            clean.add(dependency);/*  www .ja va  2  s .  com*/
        }
    });
    Collections.sort(clean);
    return clean;
}

From source file:info.losd.galenweb.web.GalenWebController.java

@RequestMapping("/")
public ModelAndView index() {
    List<GalenHealthCheck> list = client.getHealthChecks();

    List<Healthcheck> result = new LinkedList<>();
    list.forEach(item -> result.add(new Healthcheck(item)));

    return new ModelAndView("index", "healthchecks", result);
}

From source file:com.github.achatain.catalog.servlet.CollectionServlet.java

@Override
protected void doGet(final HttpServletRequest req, final HttpServletResponse resp)
        throws ServletException, IOException {
    final String userId = getUserId(req);
    LOG.info(format("List all collections for user [%s]", userId) + req.getRequestURI());
    final List<CollectionDto> collections = collectionService.listCollections(userId);
    collections.forEach(col -> {
        final String href = format("%s%s", appendIfMissing(req.getRequestURL().toString(), "/"), col.getId());
        col.addLink(Link.create().withRel("self").withMethod(Link.Method.GET).withHref(href).build());
    });//  ww w . j a  v a  2s .co m
    sendResponse(resp, collections);
}

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

private void printLog() throws IOException {
    println("--- Log file ---");

    List<String> logLines = FileUtils.readLines(logFile);
    logLines.forEach(this::println);

    println("---------------------------------");
    println();/*from   ww w . j a  va  2s .co  m*/
}