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.pitt.dbmi.ccd.db.specification.GroupSpecification.java

private static List<Predicate> inNameOrDescription(Root<Group> root, CriteriaBuilder cb, Set<String> terms) {
    return terms.stream().map(t -> containsLike(t))
            .map(t -> cb.or(nameContains(root, cb, t), descriptionContains(root, cb, t)))
            .collect(Collectors.toList());
}

From source file:com.epam.ta.reportportal.ws.converter.ProjectRelatedResourceAssembler.java

/**
 * Creates {@link com.epam.ta.reportportal.ws.model.Page} from {@link Page} DB query result
 *
 * @param content//from  w  w  w .j  av  a  2 s.  c  o m
 * @return
 */
public com.epam.ta.reportportal.ws.model.Page<R> toPagedResources(Page<T> content, final String project) {
    Assert.notNull(content);

    return new com.epam.ta.reportportal.ws.model.Page<R>(
            content.getContent().stream().map(c -> toResource(c, project)).collect(Collectors.toList()),
            new com.epam.ta.reportportal.ws.model.Page.PageMetadata(content.getSize(), content.getNumber() + 1,
                    content.getTotalElements(), content.getTotalPages()));
}

From source file:com.spartasystems.holdmail.mapper.MessageListMapper.java

protected MessageListItem toMessageListItem(MessageEntity entity) {

    List<String> recipients = entity.getRecipients().stream().map(MessageRecipientEntity::getRecipientEmail)
            .collect(Collectors.toList());

    String recipientString = StringUtils.join(recipients, ", ");

    return new MessageListItem(entity.getMessageId(), entity.getReceivedDate().getTime(),
            entity.getSenderEmail(), recipientString, entity.getSubject());
}

From source file:org.homiefund.api.dto.UserDTO.java

public void setHomes(Collection<HomeDTO> homes) {
    authorities = new ArrayList<>(homes.stream().map(h -> new SimpleGrantedAuthority(h.getId().toString()))
            .collect(Collectors.toList()));
}

From source file:com.github.rutledgepaulv.qbuilders.structures.FieldPath.java

public FieldPath append(FieldPath... path) {
    List<FieldNamespace> newChain = new LinkedList<>();
    newChain.addAll(this.chain);
    newChain.addAll(Arrays.stream(path).flatMap($ -> $.chain.stream()).collect(Collectors.toList()));
    return new FieldPath(newChain);
}

From source file:com.netflix.spinnaker.clouddriver.kubernetes.provider.KubernetesModelUtil.java

private static boolean someSucceededRemainingUnknown(List<Map<String, String>> healthsList) {
    List<Map<String, String>> knownHealthList = healthsList.stream()
            .filter(h -> !stateEquals(h, HealthState.Unknown)).collect(Collectors.toList());

    return !knownHealthList.isEmpty()
            && knownHealthList.stream().allMatch(h -> stateEquals(h, HealthState.Succeeded));
}

From source file:edu.usu.sdl.openstorefront.web.action.test.ServiceTest.java

@HandlesEvent("RunTest")
public Resolution runTest() {
    testSuites = listOfTestSuites();/*from  w  w  w  .  j a v  a 2  s  .c  o  m*/

    if (StringUtils.isNotBlank(suite)) {
        testSuites = testSuites.stream().filter(item -> item.getName().equals(suite))
                .collect(Collectors.toList());
        if (StringUtils.isNotBlank(test)) {
            TestSuiteModel specificTestModel = new TestSuiteModel();
            specificTestModel.setName("Single Test");
            for (TestSuiteModel testSuiteModel : testSuites) {
                specificTestModel.getTests().addAll(testSuiteModel.getTests().stream()
                        .filter(item -> item.getDescription().equals(test)).collect(Collectors.toList()));
            }
            testSuites = new ArrayList<>();
            testSuites.add(specificTestModel);
        }
    }
    testSuites.forEach(testSuite -> {
        testSuite.runAllTests();
    });
    return printAndSendReport(testSuites);
}

From source file:com.netflix.spinnaker.orca.clouddriver.tasks.providers.aws.AmazonImageFinder.java

@Override
public Collection<ImageDetails> byTags(Stage stage, String packageName, Map<String, String> tags) {
    StageData stageData = (StageData) stage.mapTo(StageData.class);
    List<AmazonImage> allMatchedImages = oortService
            .findImage(getCloudProvider(), packageName, null, null, prefixTags(tags)).stream()
            .map(image -> objectMapper.convertValue(image, AmazonImage.class)).sorted()
            .collect(Collectors.toList());

    List<ImageDetails> imageDetails = new ArrayList<>();

    /*/*w  w w . ja v a2s.  com*/
     * For each region, find the most recently created image.
     * (optimized for readability over efficiency given the generally small # of images)
     */
    stageData.regions
            .forEach(region -> allMatchedImages.stream().filter(image -> image.amis.containsKey(region))
                    .findFirst().map(image -> imageDetails.add(image.toAmazonImageDetails(region))));

    return imageDetails;
}

From source file:edu.pitt.dbmi.ccd.db.specification.VocabularySpecification.java

private static List<Predicate> inNameOrDescription(Root<Vocabulary> root, CriteriaBuilder cb,
        Set<String> terms) {
    return terms.stream().map(t -> containsLike(t))
            .map(t -> cb.or(nameContains(root, cb, t), descriptionContains(root, cb, t)))
            .collect(Collectors.toList());
}

From source file:it.reply.orchestrator.service.commands.GetProvidersRank.java

@Override
protected RankCloudProvidersMessage customExecute(RankCloudProvidersMessage rankCloudProvidersMessage) {

    if (rankCloudProvidersMessage.getCloudProviders().isEmpty()) {
        // nothing to rank
        return rankCloudProvidersMessage;
    }/* w  ww.  jav a  2  s  .  c om*/
    // Prepare Ranker's request
    List<Monitoring> monitoring = rankCloudProvidersMessage.getCloudProvidersMonitoringData().entrySet()
            .stream().map(e -> new Monitoring(e.getKey(), e.getValue())).collect(Collectors.toList());

    List<PreferenceCustomer> preferences = Lists.newArrayList();
    if (!rankCloudProvidersMessage.getSlamPreferences().getPreferences().isEmpty()) {
        preferences = rankCloudProvidersMessage.getSlamPreferences().getPreferences().get(0).getPreferences();
    }
    CloudProviderRankerRequest cprr = new CloudProviderRankerRequest().withPreferences(preferences)
            .withSla(rankCloudProvidersMessage.getSlamPreferences().getSla()).withMonitoring(monitoring);

    // Get provider rank and save in message
    rankCloudProvidersMessage.setRankedCloudProviders(cloudProviderRankerService.getProviderRanking(cprr));

    return rankCloudProvidersMessage;
}