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:net.sf.jabref.logic.search.DatabaseSearcher.java

public List<BibEntry> getMatches() {
    LOGGER.debug("Search term: " + query);

    if (!query.isValid()) {
        LOGGER.warn("Search failed: illegal search expression");
        return Collections.emptyList();
    }//w ww . j av  a2  s . c  o  m

    List<BibEntry> matchEntries = database.getEntries().stream().filter(query::isMatch)
            .collect(Collectors.toList());
    return BibDatabases.purgeEmptyEntries(matchEntries);
}

From source file:fi.helsinki.opintoni.service.converter.StudyAttainmentConverter.java

public StudyAttainmentDto toDto(OodiStudyAttainment oodiStudyAttainment, Locale locale) {
    return new StudyAttainmentDto(oodiStudyAttainment.studyAttainmentId,
            localizedValueConverter.toLocalizedString(oodiStudyAttainment.learningOpportunityName, locale),
            oodiStudyAttainment.teachers.stream().map(this::convertOodiTeacherToDto)
                    .collect(Collectors.toList()),
            oodiStudyAttainment.attainmentDate, oodiStudyAttainment.grade, oodiStudyAttainment.credits);
}

From source file:com.netflix.spinnaker.igor.build.BuildCache.java

public List<String> getJobNames(String master) {
    List<String> jobs = new ArrayList<>();
    redisClientDelegate.withKeyScan(baseKey() + ":completed:" + master + ":*", 1000, page -> jobs
            .addAll(page.getResults().stream().map(BuildCache::extractJobName).collect(Collectors.toList())));
    jobs.sort(Comparator.naturalOrder());
    return jobs;//from ww  w.j  a  v  a  2 s . co m
}

From source file:org.echocat.marquardt.example.keyprovisioning.KeyFileReadingTrustedKeysProvider.java

private Collection<PublicKey> loadKeys(final String publicKeyFiles) {
    return Arrays.stream(publicKeyFiles.split(",")).map(p -> loadPublicKey(p.trim()))
            .collect(Collectors.toList());
}

From source file:org.openlmis.fulfillment.web.shipment.ShipmentDtoBuilder.java

/**
 * Create a new list of {@link ShipmentDto} based on data
 * from {@link Shipment}.//from w w  w.  ja  v  a2 s. c o  m
 *
 * @param shipments collection used to create {@link ShipmentDto} list (can be {@code null})
 * @return new list of {@link ShipmentDto}. Empty list if passed argument is {@code null}.
 */
public List<ShipmentDto> build(Collection<Shipment> shipments) {
    if (null == shipments) {
        return Collections.emptyList();
    }
    return shipments.stream().map(this::export).collect(Collectors.toList());
}

From source file:com.netflix.spinnaker.clouddriver.kubernetes.v2.description.manifest.KubernetesMultiManifestOperationDescription.java

public List<KubernetesCoordinates> getAllCoordinates() {
    return kinds.stream().map(
            k -> KubernetesCoordinates.builder().namespace(location).kind(KubernetesKind.fromString(k)).build())
            .collect(Collectors.toList());
}

From source file:com.karusmc.commandwork.reference.help.HelpParser.java

public List<String> getCommandUsages(Collection<CommandCallable> commands,
        Predicate<CommandCallable> predicate) {
    return commands.stream().filter(predicate).map(subcommand -> ChatColor.GOLD + subcommand.getUsage())
            .collect(Collectors.toList());
}

From source file:de.micromata.mgc.jpa.hibernatesearch.impl.LuceneDebugUtils.java

public String getIndexDescription(SearchEmgrFactory<?> emfac, Class<?> entityClass) {
    StringBuilder sb = new StringBuilder();
    emfac.runInTrans((emgr) -> {/*from w w  w .  jav  a 2s  .  c  o m*/
        sb.append("class: ").append(entityClass.getName()).append("\n");

        FullTextEntityManager femg = emgr.getFullTextEntityManager();
        SearchFactory sf = femg.getSearchFactory();
        IndexedTypeDescriptor itd = sf.getIndexedTypeDescriptor(entityClass);
        List<String> fields = itd.getIndexedProperties().stream().map((desc) -> desc.getName())
                .collect(Collectors.toList());
        sb.append("\nFields: ").append(StringUtils.join(fields, ", ")).append("\n");

        IndexedTypeDescriptor descr = sf.getIndexedTypeDescriptor(entityClass);
        sb.append("\nIndexedTypeDescriptor: indexed: ").append(descr.isIndexed()).append("\nFields:\n");
        for (FieldDescriptor field : descr.getIndexedFields()) {
            sb.append("  ").append(field).append("<br?\n");
        }
        sb.append("\nProperties: \n");
        for (PropertyDescriptor ip : descr.getIndexedProperties()) {
            sb.append("  ").append(ip).append("\n");
        }

        sb.append("\nIndexe: \n");
        for (IndexDescriptor ides : descr.getIndexDescriptors()) {
            sb.append("  ").append(ides).append("\n");
        }

        String[] sfields = getSearchFieldsForEntity(emfac, entityClass);
        sb.append("\nSearchFields: ").append(StringUtils.join(sfields, ",")).append("\n");
        return null;
    });
    return sb.toString();
}

From source file:gobblin.source.extractor.extract.kafka.ConfigStoreUtils.java

/**
 * Will return the list of URIs given which are importing tag {@param tagUri}
 *///from   ww w.  j  a  va  2s.  c om
public static Collection<URI> getTopicsURIFromConfigStore(ConfigClient configClient, Path tagUri,
        String filterString, Optional<Config> runtimeConfig) {
    try {
        Collection<URI> importedBy = configClient.getImportedBy(new URI(tagUri.toString()), true,
                runtimeConfig);
        return importedBy.stream().filter((URI u) -> u.toString().contains(filterString))
                .collect(Collectors.toList());
    } catch (URISyntaxException | ConfigStoreFactoryDoesNotExistsException | ConfigStoreCreationException e) {
        throw new Error(e);
    }
}

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

public List<CourseRecommendationDto> getCourseRecommendations(String studentNumber, Locale locale) {
    return leikiClient.getCourseRecommendations(studentNumber).stream()
            .map(courseRecommendation -> courseRecommendationConverter.toDto(courseRecommendation, locale))
            .collect(Collectors.toList());
}