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:org.ng200.openolympus.controller.api.UserSearchController.java

@RequestMapping("/api/userCompletion")
public @ResponseBody List<String> searchUsers(@RequestParam(value = "term") final String name) {
    Assertions.resourceExists(name);//w ww  . ja va 2 s  .  c  om

    return this.userRepository.findByUsernameContaining(name, new PageRequest(0, 30)).stream()
            .map((user) -> user.getUsername()).collect(Collectors.toList());
}

From source file:com.github.drbookings.ui.BookingsByOrigin.java

public Collection<T> getAllBookings(final boolean cheat) {
    if (cheat) {// w  w w.ja  v  a2  s.  c o  m
        return bookingEntries.stream().filter(b -> !StringUtils.isBlank(b.getBookingOrigin().getName()))
                .collect(Collectors.toList());
    }
    return bookingEntries;
}

From source file:org.obiba.mica.project.rest.PublishedProjectsResource.java

@GET
@Path("/projects")
@Timed/* w w  w  . j a va  2s .  co m*/
public Mica.ProjectsDto list(@QueryParam("from") @DefaultValue("0") int from,
        @QueryParam("limit") @DefaultValue("10") int limit, @QueryParam("sort") String sort,
        @QueryParam("order") String order, @QueryParam("query") String query) {

    PublishedDocumentService.Documents<Project> projects = publishedProjectService.find(from, limit, sort,
            order, null, query);

    Mica.ProjectsDto.Builder builder = Mica.ProjectsDto.newBuilder();

    builder.setFrom(projects.getFrom()).setLimit(projects.getLimit()).setTotal(projects.getTotal());
    builder.addAllProjects(projects.getList().stream().map(dtos::asDto).collect(Collectors.toList()));

    return builder.build();
}

From source file:com.gooddata.notification.Subscription.java

/**
 * Creates Subscription//  w w w .  j  a  v  a  2 s. c o  m
 *
 * @param triggers triggers of subscription
 * @param channels list of {@link Channel}
 * @param condition condition under which this subscription activates
 * @param template of message
 * @param title name of subscription
 */
public Subscription(final List<Trigger> triggers, final List<Channel> channels,
        final TriggerCondition condition, final MessageTemplate template, final String title) {
    this(notNull(triggers, "triggers"), notNull(condition, "condition"), notNull(template, "template"),
            notNull(channels, "channels").stream().map(e -> e.getMeta().getUri()).collect(Collectors.toList()),
            new Meta(notEmpty(title, "title")));
}

From source file:uk.ac.ebi.ep.controller.BrowsePathwaysController.java

@RequestMapping(value = BROWSE_PATHWAYS, method = RequestMethod.GET)
public String showPathways(Model model) {
    EnzymeFinder finder = new EnzymeFinder(enzymePortalService, ebeyeRestService);

    pathwayList = finder.findAllPathways().stream().distinct().collect(Collectors.toList());
    String msg = String.format("Number of pathways found : %s", pathwayList.size());
    LOGGER.debug(msg);/*from  w  w  w .j  av  a2 s  . c o  m*/

    SearchModel searchModelForm = searchform();
    model.addAttribute("searchModel", searchModelForm);
    model.addAttribute("pathwayList", pathwayList);

    return PATHWAYS;
}

From source file:ee.ria.xroad.common.certificateprofile.impl.AbstractCertificateProfileInfo.java

@Override
public X500Principal createSubjectDn(DnFieldValue[] values) {
    return new X500Principal(
            StringUtils.join(Arrays.stream(values).map(this::toString).collect(Collectors.toList()), ", "));
}

From source file:ninja.eivind.hotsreplayuploader.utils.StormHandler.java

/**
 * Retrieves a {@link List} of {@link File}s, which represent
 * the replay file directory for a specific {@link Account}.
 * @return {@link List} of directories or an empty {@link List}
 *///from   w  w w. java  2s.  co m
public List<File> getReplayDirectories() {
    return getAccountDirectories().stream().map(StormHandler::getReplayDirectory).collect(Collectors.toList());
}

From source file:io.knotx.knot.action.ActionKnotConfiguration.java

public ActionKnotConfiguration(JsonObject config) {
    this.address = config.getString("address");
    this.formIdentifierName = config.getString("formIdentifierName");
    this.adapterMetadataList = config.getJsonArray("adapters").stream().map(item -> (JsonObject) item)
            .map(item -> {//from ww w  .  j av  a  2 s  . c  om
                AdapterMetadata metadata = new AdapterMetadata();
                metadata.name = item.getString("name");
                metadata.address = item.getString("address");
                metadata.params = item.getJsonObject("params", new JsonObject()).getMap();
                metadata.allowedRequestHeaders = item.getJsonArray("allowedRequestHeaders", new JsonArray())
                        .stream().map(object -> (String) object).map(new StringToPatternFunction())
                        .collect(Collectors.toList());
                metadata.allowedResponseHeaders = item.getJsonArray("allowedResponseHeaders", new JsonArray())
                        .stream().map(object -> (String) object).map(new StringToPatternFunction())
                        .collect(Collectors.toList());
                return metadata;
            }).collect(Collectors.toList());
}

From source file:br.edu.ifpb.bdnc.db4o.crud.dao.Dao.java

@Override
public synchronized List<T> findParam(Class<T> clazz, Map<String, Object> param) {
    ObjectContainer db = Db4oFactory.newInstance();
    try {/*w w  w .  j  ava  2s.c o  m*/
        Query query = db.query();
        Constraint constraint = query.constrain(clazz);
        if (param != null) {
            for (Map.Entry<String, Object> entrySet : param.entrySet()) {
                constraint = query.descend(entrySet.getKey()).constrain(entrySet.getValue()).and(constraint);
            }
            return (List<T>) query.execute().stream().collect(Collectors.toList());
        }
    } finally {
        db.close();
    }
    return Collections.EMPTY_LIST;
}