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.devicehive.dao.riak.model.RiakDeviceEquipment.java

public static List<DeviceEquipmentVO> convertToVo(List<RiakDeviceEquipment> equipment) {
    if (equipment == null) {
        return Collections.emptyList();
    }/*from ww w . j av  a2s .  c  om*/
    return equipment.stream().map(RiakDeviceEquipment::convertToVo).collect(Collectors.toList());
}

From source file:com.thinkbiganalytics.metadata.rest.jobrepo.nifi.NifiFeedProcessorStatsTransform.java

/**
 * Converts the domain model objects to the rest model equivalent
 *
 * @param domains A list of domain objects
 * @return a list of converted objects, or null if the provided list was empty
 *///w w  w  .  j  a v  a  2 s.com
public static List<NifiFeedProcessorStatsErrors> toErrorsModel(
        List<? extends com.thinkbiganalytics.metadata.api.jobrepo.nifi.NifiFeedProcessorErrors> domains) {
    if (domains != null && !domains.isEmpty()) {
        return domains.stream().map(domain -> toErrorsModel(domain)).collect(Collectors.toList());
    }
    return null;
}

From source file:io.github.carlomicieli.footballdb.starter.pages.Table.java

protected Table(TableBuilder tb) {
    this.size = ImmutablePair.of(tb.size.getKey(), tb.size.getValue());
    this.headers = Collections.unmodifiableList(tb.columnHeaders);
    this.rows = tb.values.stream().map(r -> Row.of(r, headers)).collect(Collectors.toList());
}

From source file:net.dstc.mkts.api.MarketingSurveyApiImpl.java

@Override
public Collection<SurveyDTO> getList(SurveyDTO query) {
    SurveyDO daoQuery = null;// w  w  w  .  j  a v  a2  s  . c  om

    if (query != null) {
        daoQuery = getConverter().surveyDTOtoDO(query);
    }

    return data.list(daoQuery).stream().map(s -> getConverter().surveyDOtoDTO(s)).collect(Collectors.toList());
}

From source file:de.sainth.recipe.backend.db.repositories.BasicUnitRepository.java

public List<BasicUnit> findAll() {
    return create.selectFrom(BASIC_UNITS).fetch().stream()
            .map(record -> new BasicUnit(record.getShortname(), record.getLongname()))
            .collect(Collectors.toList());
}

From source file:com.thinkbiganalytics.metadata.rest.model.sla.ServiceLevelAssessmentTransform.java

public static ServiceLevelAssessment toModel(
        com.thinkbiganalytics.metadata.sla.api.ServiceLevelAssessment assessment) {
    ServiceLevelAssessment model = new ServiceLevelAssessment();
    model.setAgreement(new ServiceLevelAgreement());
    if (assessment.getServiceLevelAgreementDescription() != null) {
        if (StringUtils.isNotBlank(assessment.getServiceLevelAgreementDescription().getName())) {
            model.getAgreement().setName(assessment.getServiceLevelAgreementDescription().getName());
        }/*w  ww  . j  av a2s  .com*/
        if (StringUtils.isNotBlank(assessment.getServiceLevelAgreementDescription().getDescription())) {
            model.getAgreement()
                    .setDescription(assessment.getServiceLevelAgreementDescription().getDescription());
        }
        if (assessment.getServiceLevelAgreementDescription().getSlaId() != null) {
            model.getAgreement().setId(assessment.getServiceLevelAgreementDescription().getSlaId().toString());
        }
    }

    if (model.getAgreement().getId() == null) {
        model.getAgreement()
                .setId(assessment.getServiceLevelAgreementId() != null
                        ? assessment.getServiceLevelAgreementId().toString()
                        : null);
    }
    if (model.getAgreement().getName() == null & assessment.getAgreement() != null) {
        model.getAgreement().setName(assessment.getAgreement().getName());
    }

    if (assessment.getObligationAssessments() != null) {
        model.setObligationAssessments(assessment.getObligationAssessments().stream()
                .map(obligationAssessment -> toModel(obligationAssessment)).collect(Collectors.toList()));
    }
    model.setMessage(assessment.getMessage());
    model.setResult(ServiceLevelAssessment.Result.valueOf(assessment.getResult().name()));
    model.setTime(assessment.getTime());
    model.setId(assessment.getId().toString());
    return model;
}

From source file:com.firewallid.util.FIUtils.java

public static <U, V extends Number> List<Tuple2<U, Double>> sumList(List<Tuple2<U, V>> l1,
        List<Tuple2<U, V>> l2) {
    l1.addAll(l2);/*from  ww w.  j  av a  2  s .c  o m*/
    List<Tuple2<U, Double>> sum = l1.parallelStream()
            .collect(Collectors
                    .groupingBy(data -> data._1(), Collectors.mapping(data -> data._2(), Collectors.toList())))
            .entrySet().parallelStream()
            .map(data -> new Tuple2<>(data.getKey(),
                    data.getValue().parallelStream().mapToDouble(value -> value.doubleValue()).sum()))
            .collect(Collectors.toList());

    return sum;
}

From source file:am.ik.categolj2.api.link.LinkRestController.java

@RequestMapping(method = RequestMethod.GET)
public List<LinkResource> getLinks() {
    List<Link> links = linkService.findAll();
    return links.stream().map(link -> beanMapper.map(link, LinkResource.class)).collect(Collectors.toList());
}

From source file:com.github.steveash.guavate.GuavateTest.java

@Test
public void test_stream_Iterable() {
    Iterable<String> iterable = Arrays.asList("a", "b", "c");
    List<String> test = Guavate.stream(iterable).collect(Collectors.toList());
    assertEquals(test, ImmutableList.of("a", "b", "c"));
}

From source file:org.trustedanalytics.examples.hbase.services.ConversionsService.java

public TableDescription constructTableDescription(HTableDescriptor htd) {
    TableDescription result = null;//from ww  w . j  a v  a  2 s. com

    if (htd != null) {
        String name = htd.getNameAsString();
        Collection<HColumnDescriptor> families = htd.getFamilies();

        List<String> familiesNames = families.stream().map(HColumnDescriptor::getNameAsString)
                .collect(Collectors.toList());

        result = new TableDescription(name, familiesNames);
    }

    return result;
}