Example usage for java.util.stream Collectors toList

List of usage examples for java.util.stream Collectors toList

Introduction

In this page you can find the example usage for java.util.stream Collectors toList.

Prototype

public static <T> Collector<T, ?, List<T>> toList() 

Source Link

Document

Returns a Collector that accumulates the input elements into a new List .

Usage

From source file:com.yqboots.security.web.form.GroupFormConverter.java

/**
 * Gets the id of users.//from w w w .j av a2  s.c  o  m
 *
 * @param users users
 * @return id of users
 */
private Long[] getUsers(Set<User> users) {
    List<Long> results = new ArrayList<>();
    if (CollectionUtils.isNotEmpty(users)) {
        results.addAll(users.stream().map(User::getId).collect(Collectors.toList()));
    }

    return results.toArray(new Long[results.size()]);
}

From source file:jenkins.security.ClassFilterImplSanityTest.java

@Test
public void whitelistSanity() throws Exception {
    try (InputStream is = ClassFilterImpl.class.getResourceAsStream("whitelisted-classes.txt")) {
        List<String> lines = IOUtils.readLines(is, StandardCharsets.UTF_8).stream()
                .filter(line -> !line.matches("#.*|\\s*")).collect(Collectors.toList());
        assertThat("whitelist is NOT ordered", new TreeSet<>(lines),
                contains(lines.toArray(MemoryReductionUtil.EMPTY_STRING_ARRAY)));
        for (String line : lines) {
            try {
                Class.forName(line);
            } catch (ClassNotFoundException x) {
                System.err.println("skipping checks of unknown class " + line);
            }/* w w  w .java  2s . c o m*/
        }
    }
}

From source file:me.bulat.jivr.webmin.web.defended.admin.ConsulController.java

@RequestMapping(value = { "/admin/consul" }, method = { RequestMethod.GET })
public ModelAndView consulPage() {
    List<String> services = consul.getServiceList().stream().map(ServiceKey::getServiceName)
            .collect(Collectors.toList());
    List<String> nodes = consul.getNodeList().stream().map(NodeKey::getNodeName).collect(Collectors.toList());
    ModelAndView model = new ModelAndView();
    NodeForm nodeForm = new NodeForm();
    ServiceForm serviceForm = new ServiceForm();
    model.addObject("title", "Jivr Web Console Nodes page");
    model.addObject("message", "Nodes Page!");
    model.setViewName("admin/consul");
    model.addObject("nodeForm", nodeForm);
    model.addObject("services", services);
    model.addObject("nodes", nodes);
    model.addObject("nodeToDelete", new NodeToDelete());
    model.addObject("serviceToDelete", new ServiceToDelete());
    model.addObject("serviceForm", serviceForm);
    return model;
}

From source file:org.obiba.mica.network.search.EsDraftNetworkService.java

@Nullable
@Override/*from ww w. j a va2  s  .  c  o  m*/
protected Searcher.IdFilter getAccessibleIdFilter() {
    return new Searcher.IdFilter() {
        @Override
        public Collection<String> getValues() {
            return networkService.findAllIds().stream()
                    .filter(s -> subjectAclService.isPermitted("/draft/network", "VIEW", s))
                    .collect(Collectors.toList());
        }
    };
}

From source file:org.obiba.mica.project.search.EsDraftProjectService.java

@Nullable
@Override// w  w  w  . j  a v a 2s. com
protected Searcher.IdFilter getAccessibleIdFilter() {
    return new Searcher.IdFilter() {
        @Override
        public Collection<String> getValues() {
            return projectService.findAllIds().stream()
                    .filter(s -> subjectAclService.isPermitted("/draft/project", "VIEW", s))
                    .collect(Collectors.toList());
        }
    };
}

From source file:lumbermill.elasticsearch.ElasticSearchBulkResponseEvent.java

private static ObjectNode buildJsonResponse(boolean hasErrors, Map<JsonEvent, JsonEvent> eventAndResponse) {
    ObjectNode node = Json.OBJECT_MAPPER.createObjectNode().put("errors", hasErrors).put("took", 1L);
    node.putArray("items").addAll(eventAndResponse.values().stream().map(jsonEvent -> jsonEvent.copyNode())
            .collect(Collectors.toList()));
    return node;/*  ww  w  .  ja v a 2s  .co  m*/

}

From source file:org.travis4j.rest.Request.java

private <T> List<String> toStringList(Collection<T> values) {
    return values.stream().map(Objects::toString).collect(Collectors.toList());
}

From source file:pt.ist.fenix.ui.spring.ChannelsController.java

@RequestMapping
public String bookmarks(Model model, @RequestParam(required = false) ExecutionSemester semester,
        @RequestParam(required = false) ExecutionDegree degree) {
    model.addAttribute("executions", Bennu.getInstance().getExecutionPeriodsSet().stream()
            .sorted(Comparator.reverseOrder()).collect(Collectors.toList()));
    if (semester != null) {
        model.addAttribute("selectedSemester", semester);
        model.addAttribute("degrees", semester.getExecutionYear().getExecutionDegreesSortedByDegreeName());
    }/*from   w w  w  .  j a v a2  s.  co m*/
    if (semester != null && degree != null) {
        model.addAttribute("selectedDegree", degree);
        model.addAttribute("courses",
                semester.getAssociatedExecutionCoursesSet().stream()
                        .filter(course -> isExecutionCourseForExecutionDegree(course, degree))
                        .sorted(ExecutionCourse.EXECUTION_COURSE_NAME_COMPARATOR).collect(Collectors.toList()));
    }
    model.addAttribute("bookmarks", Authenticate.getUser().getBookmarksSet());
    model.addAttribute("slugs", ImmutableSet.of("announcement", "summary"));
    return "fenix-learning/channels";
}

From source file:com.skelril.nitro.droptable.DropTableImpl.java

@Override
public Collection<ItemStack> getDrops(int quantity, double modifier, DiceRoller roller) {
    List<ItemStack> results = new ArrayList<>();

    for (int i = 0; i < quantity; ++i) {
        Collection<DropTableEntry> hits = roller.getHits(possible, modifier);
        for (DropTableEntry entry : hits) {
            entry.enque(modifier);//ww w  .ja  v  a2s  . c  om
        }
    }

    for (DropTableEntry entry : possible) {
        results.addAll(entry.flush());
    }

    return results.stream().map(ItemStack::copy).collect(Collectors.toList());
}

From source file:com.spotify.styx.api.deprecated.RunStateDataPayload.java

public static RunStateDataPayload create(com.spotify.styx.api.RunStateDataPayload runStateDataPayload) {
    return new AutoValue_RunStateDataPayload(
            runStateDataPayload.activeStates().stream().map(RunStateData::create).collect(Collectors.toList()));
}