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.przemo.projectmanagementweb.services.TaskService.java

@Override
public Task createNewTask() {
    Task t = new Task();
    t.setStatus(getAvailableStatuses().stream().filter(o -> o.getName().equals("Created"))
            .collect(Collectors.toList()).get(0));
    return t;//  ww w.ja v a 2  s  . c  o  m
}

From source file:org.hawkular.services.rest.test.InventoryHelper.java

static List<ExtendedInventoryStructure> extractStructuresFromResponse(JsonNode response) {
    return StreamSupport.stream(response.spliterator(), true).map(node -> node.get("data"))
            .map(InventoryHelper::rebuildFromChunks).filter(Optional::isPresent).map(Optional::get)
            .collect(Collectors.toList());
}

From source file:com.hurence.logisland.connect.opc.CommonUtils.java

/**
 * Extract structured info from tag properties.
 *
 * @param properties the tag properties given by the OPC connector
 * @return a list of {@link TagInfo}//from w  ww. j  a  v a 2 s . co m
 */
public static final List<TagInfo> parseTagsFromProperties(Map<String, String> properties) {

    List<String> tagIds = Arrays.asList(properties.get(CommonDefinitions.PROPERTY_TAGS_ID).split(","));
    List<Duration> tagSamplings = Arrays
            .stream(properties.get(CommonDefinitions.PROPERTY_TAGS_SAMPLING_RATE).split(","))
            .map(Duration::parse).collect(Collectors.toList());
    List<StreamingMode> tagModes = Arrays
            .stream(properties.get(CommonDefinitions.PROPERTY_TAGS_STREAM_MODE).split(","))
            .map(StreamingMode::valueOf).collect(Collectors.toList());
    List<TagInfo> ret = new ArrayList<>();
    for (int i = 0; i < tagIds.size(); i++) {
        ret.add(new TagInfo(tagIds.get(i), tagSamplings.get(i), tagModes.get(i)));
    }
    return ret;

}

From source file:com.pablinchapin.planz.dailytaskmanager.client.service.TaskServiceBean.java

public List<TaskServiceDTO> findAll() {
    return Arrays.stream(restTemplate.getForObject(resource, TaskServiceDTO[].class))
            .collect(Collectors.toList());
}

From source file:com.spotify.styx.schedule.model.deprecated.ScheduleDefinition.java

public static com.spotify.styx.schedule.model.ScheduleDefinition create(ScheduleDefinition scheduleDefinition) {
    return com.spotify.styx.schedule.model.ScheduleDefinition.create(scheduleDefinition.workflowConfigurations()
            .stream().map(WorkflowConfiguration::create).collect(Collectors.toList()));
}

From source file:io.knotx.adapter.common.placeholders.UriTransformer.java

protected static List<String> getPlaceholders(String serviceUri) {
    return Arrays.asList(serviceUri.split("\\{")).stream().filter(str -> str.contains("}"))
            .map(str -> StringUtils.substringBefore(str, "}")).collect(Collectors.toList());
}

From source file:persistence.mongodb.security.MongoBeanMapper.java

public List<DocumentAccessPermission> newDocumentAccessPermissionsDtoList(
        List<DocumentAccessPermissionBean> documentAccessRights) {
    return documentAccessRights.stream().map(this::newDocumentAccessPermissionDto).collect(Collectors.toList());
}

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();/* w ww.java  2 s  .c  om*/
    }));
    return container.withExposedPorts(WIRE_MOCK_PORT)
            .waitingFor(container.waitStrategy().withStartupTimeout(CONTAINER_STARTUP_TIMEOUT));
}

From source file:com.hubrick.vertx.s3.util.UrlEncodingUtils.java

public static String addParamsSortedToUrl(String url, Map<String, String> params) {
    checkNotNull(url, "url must not be null");
    checkNotNull(!url.isEmpty(), "url must not be empty");
    checkNotNull(params, "params must not be null");
    checkNotNull(!params.isEmpty(), "params must not be empty");

    final String baseUrl = extractBaseUrl(url);
    final String urlParams = baseUrl.equals(url) ? "" : url.replace(baseUrl + "?", "");
    final List<NameValuePair> nameValuePairs = URLEncodedUtils.parse(urlParams, Charsets.UTF_8);

    for (Map.Entry<String, String> paramToUrlEncode : params.entrySet().stream()
            .sorted(Comparator.comparing(Map.Entry::getKey)).collect(Collectors.toList())) {
        nameValuePairs.add(new BasicNameValuePair(paramToUrlEncode.getKey(), paramToUrlEncode.getValue()));
    }//ww w  .j  av  a  2s . c o  m

    return baseUrl + "?" + URLEncodedUtils.format(nameValuePairs, Charsets.UTF_8);
}

From source file:com.rorrell.zootest.rest.ExhibitRest.java

@RequestMapping(value = "/exhibits-by-environment", method = RequestMethod.GET)
public List<Exhibit> getExhibitsByEnvironment(@RequestParam("env") long envId) {
    return exhibitRepo.findByEnvironmentId(envId).stream().map(ex -> {
        ex.setAnimals(null);/*from   ww w  . j  a va 2 s  . c  om*/
        ex.setEnvironment(null);
        return ex;
    }).collect(Collectors.toList());
}