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.netflix.spinnaker.config.SwaggerConfig.java

private Predicate<String> paths() {
    return or(patterns.stream().map(PathSelectors::regex).collect(Collectors.toList()));
}

From source file:com.netflix.spinnaker.halyard.deploy.deployment.v1.BakeDeployer.java

@Override
public RemoteAction deploy(BakeServiceProvider serviceProvider, DeploymentDetails deploymentDetails,
        GenerateService.ResolvedConfiguration resolvedConfiguration, List<String> serviceNames) {
    List<BakeService> enabledServices = serviceProvider.getPrioritizedBakeableServices(serviceNames).stream()
            .filter(i -> resolvedConfiguration.getServiceSettings(i.getService()).getEnabled())
            .collect(Collectors.toList());

    Map<String, String> installCommands = enabledServices.stream().reduce(new HashMap<>(),
            (commands, installable) -> {
                String command = String.join("\n", installable.installArtifactCommand(deploymentDetails),
                        installable.stageStartupScripts(resolvedConfiguration));
                commands.put(installable.getService().getCanonicalName(), command);
                return commands;
            }, (m1, m2) -> {/*from   w  w  w  .  j  a va2  s . c  om*/
                m1.putAll(m2);
                return m1;
            });

    String startupCommand = String.join("\n", enabledServices.stream().map(BakeService::getStartupCommand)
            .filter(Objects::nonNull).collect(Collectors.toList()));

    String installCommand = serviceProvider.getInstallCommand(resolvedConfiguration, installCommands,
            startupCommand);
    RemoteAction result = new RemoteAction();
    result.setAutoRun(true);
    result.setScript(installCommand);
    return result;
}

From source file:com.netflix.spinnaker.fiat.providers.DefaultServiceAccountProvider.java

@Override
public Set<ServiceAccount> getAllRestricted(@NonNull Set<Role> roles) throws ProviderException {
    List<String> roleNames = roles.stream().map(Role::getName).collect(Collectors.toList());
    return getAll().stream().filter(svcAcct -> !svcAcct.getMemberOf().isEmpty())
            .filter(svcAcct -> roleNames.containsAll(svcAcct.getMemberOf())).collect(Collectors.toSet());
}

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

public List<DocumentAccessPermissionBean> newDocumentAccessPermissionsList(
        final List<DocumentAccessPermission> beans) {
    return beans.stream().map(this::newDocumentAccessPermission).collect(Collectors.toList());
}

From source file:mesclasses.handlers.StatsHandler.java

/**
 * retourne toutes les seances d'un lve avec absence, sur un trimestre
 * @param eleve//from w ww.  ja va2 s . c o m
 * @param trimestre
 * @return 
 */
public List<Seance> getSeancesWithAbsenceOnTrimestre(Eleve eleve, Trimestre trimestre) {
    return getDonneesForPeriode(eleve, trimestre.getStartAsDate(), trimestre.getEndAsDate())
            .filter(d -> d.isAbsent()).map(d -> d.getSeance()).collect(Collectors.toList());
}

From source file:com.thinkbiganalytics.common.velocity.service.InMemoryVelocityTemplateProvider.java

@Override
public List<? extends VelocityTemplate> findEnabledByType(String type) {
    return map.values().stream().filter(t -> t.getType().equalsIgnoreCase(type) && t.isEnabled())
            .collect(Collectors.toList());
}

From source file:io.gravitee.repository.redis.management.RedisEventRepository.java

@Override
public Page<Event> search(EventCriteria filter, Pageable pageable) {
    Page<RedisEvent> pagedEvents = eventRedisRepository.search(filter, pageable);

    return new Page<>(pagedEvents.getContent().stream().map(this::convert).collect(Collectors.toList()),
            pagedEvents.getPageNumber(), (int) pagedEvents.getTotalElements(), pagedEvents.getTotalElements());
}

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

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

From source file:com.example.app.profile.ui.user.LoginLandingLinks.java

/**
 * Get available links./*from  w ww  .j  av  a  2 s.  c o  m*/
 *
 * @param currentUser the current user.
 * @param lc the locale context.
 *
 * @return the list of links.
 */
static List<Link> getAvailableLinks(User currentUser, LocaleContext lc) {
    final DAOs daos = new DAOs();
    final List<Membership> memberships = daos.profileDAO.getMembershipsForUser(currentUser,
            "membership.lastModTime desc", AppUtil.UTC);
    return Arrays.stream(LoginLandingLinks.values())
            .map(availbaleLinks -> availbaleLinks.getLink(memberships, lc))
            .flatMap(link -> link.map(Stream::of).orElseGet(Stream::empty)).collect(Collectors.toList());

}

From source file:com.create.validation.PropertyValidationErrorsProvider.java

private Map<String, List<String>> getPropertyValidationErrorsGroupedByNestedPath(
        List<ObjectError> objectErrors) {
    return objectErrors.stream().map(this::toPropertyValidationError)
            .collect(Collectors.groupingBy(PropertyValidationError::getNestedPath,
                    Collectors.mapping(PropertyValidationError::getMessage, Collectors.toList())));
}