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:edu.washington.gs.skyline.model.quantification.QuantificationTest.java

public void testNoNormalization() throws Exception {
    List<InputRecord> allInputRecords = readInputRecords("NoNormalizationInput.csv");
    allInputRecords = filterRecords(NormalizationMethod.NONE, allInputRecords);
    Map<RecordKey, Double> expected = readExpectedRows("NoNormalizationExpected.csv");
    for (Map.Entry<RecordKey, Double> entry : expected.entrySet()) {
        List<InputRecord> peptideRecords = allInputRecords.stream()
                .filter(record -> record.getRecordKey().getPeptideKey().equals(entry.getKey().getPeptideKey()))
                .collect(Collectors.toList());
        TransitionKeys allTransitionKeys = TransitionKeys
                .of(peptideRecords.stream().map(InputRecord::getTransitionKey).collect(Collectors.toSet()));
        List<InputRecord> replicateRecords = allInputRecords.stream()
                .filter(record -> record.getRecordKey().equals(entry.getKey())).collect(Collectors.toList());
        Map<String, Double> areaMap = replicateRecords.stream()
                .collect(Collectors.toMap(InputRecord::getTransitionKey, InputRecord::getArea));
        TransitionAreas transitionAreas = TransitionAreas.fromMap(areaMap);
        assertCloseEnough(entry.getValue(), transitionAreas.totalArea(allTransitionKeys));
    }/*from w  w w  . java2  s.com*/
}

From source file:com.heliosdecompiler.helios.controller.RecentFileController.java

public List<File> getRecentFiles() {
    return configuration.getList(String.class, Settings.RECENT_FILES_KEY, Collections.emptyList()).stream()
            .map(File::new).collect(Collectors.toList());
}

From source file:com.khartec.waltz.jobs.sample.AssetCostGenerator.java

private static List<AssetCostRecord> generateRecords(ApplicationService applicationService, CostKind kind,
        int mean) {
    return applicationService.findAll().stream().filter(a -> a.assetCode().isPresent())
            .map(a -> ImmutableAssetCost.builder().assetCode(a.assetCode().get()).cost(ImmutableCost.builder()
                    .currencyCode("EUR").amount(generateAmount(mean)).year(year).kind(kind).build()).build())
            .map(c -> {/*w w w.j av a2  s.com*/
                AssetCostRecord record = new AssetCostRecord();
                record.setAssetCode(c.assetCode());
                record.setAmount(c.cost().amount());
                record.setCurrency(c.cost().currencyCode());
                record.setKind(c.cost().kind().name());
                record.setYear(c.cost().year());
                return record;
            }).collect(Collectors.toList());
}

From source file:fi.helsinki.opintoni.service.SearchService.java

public List<CategoryHitDto> searchCategory(String searchTerm, Locale locale) throws Exception {
    return leikiClient.searchCategory(searchTerm, locale).stream().map(categoryHitConverter::toDto)
            .collect(Collectors.toList());
}

From source file:mesclasses.objects.LoadWindow.java

private List<String> getTaskNames() {
    return services.stream().map(LoadingService::getTaskName).collect(Collectors.toList());
}

From source file:am.ik.categolj3.api.category.InMemoryCategoryService.java

@Override
public List<List<String>> findAllOrderByNameAsc() {
    return this.categories.values().stream().distinct()
            .sorted(Comparator.comparing(categories -> String.join(",", categories)))
            .collect(Collectors.toList());
}

From source file:org.openmhealth.dsu.repository.ClientDetailsRepositoryIntegrationTests.java

protected List<GrantedAuthority> asGrantedAuthorities(Collection<String> roles) {

    return roles.stream().map(SimpleGrantedAuthority::new).collect(Collectors.toList());
}

From source file:io.gravitee.gateway.handlers.api.policy.api.ApiPolicyChainResolver.java

@Override
protected List<Policy> calculate(StreamType streamType, Request request, Response response,
        ExecutionContext executionContext) {
    // Resolve the "configured" path according to the inbound request
    Path path = pathResolver.resolve(request.path());
    executionContext.setAttribute(ExecutionContext.ATTR_RESOLVED_PATH, path.getResolvedPath());

    return path.getRules().stream()
            .filter(rule -> rule.isEnabled() && rule.getMethods().contains(request.method()))
            .map(rule -> create(streamType, rule.getPolicy().getName(), rule.getPolicy().getConfiguration()))
            .filter(Objects::nonNull).collect(Collectors.toList());
}

From source file:com.davidmogar.alsa.services.bus.internal.BusManagerServiceImpl.java

@Override
public List<BusDto> findByLicensePlateLike(String licensePlate) {
    return StreamSupport
            .stream(busDataService.findByLicensePlateLike("%" + licensePlate + "%").spliterator(), false)
            .map(BusDto::new).collect(Collectors.toList());
}

From source file:org.lendingclub.mercator.aws.RouteTableScanner.java

@Override
protected void doScan() {
    GraphNodeGarbageCollector gc = newGarbageCollector().bindScannerContext();
    getClient().describeRouteTables().getRouteTables().forEach(rt -> {

        ObjectNode n = convertAwsObject(rt, getRegion());

        NeoRxClient neo4j = getNeoRxClient();
        try {/*from   w  w  w.  j  a  v  a2  s . c  om*/
            String cypher = "merge (x:AwsRouteTable {aws_arn:{arn}}) set x+={props}, x.updateTs=timestamp() return x";
            String arn = n.path("aws_arn").asText();
            neo4j.execCypher(cypher, "arn", arn, "props", n).forEach(it -> {
                gc.MERGE_ACTION.accept(it);
            });

            LinkageHelper subnetLinkage = new LinkageHelper().withNeo4j(neo4j).withFromLabel(getNeo4jLabel())
                    .withFromArn(arn).withTargetLabel("AwsSubnet").withLinkLabel("ATTACHED_TO")
                    .withTargetValues(rt.getAssociations().stream()
                            .filter(a -> !Strings.isNullOrEmpty(a.getSubnetId()))
                            .map(a -> createEc2Arn("subnet", a.getSubnetId())).collect(Collectors.toList()));
            subnetLinkage.execute();

            incrementEntityCount();
        } catch (RuntimeException e) {
            gc.markException(e);
            maybeThrow(e);
        }
    });
}