List of usage examples for java.util.stream Collectors toList
public static <T> Collector<T, ?, List<T>> toList()
From source file:de.micromata.genome.logging.web.FormUrlEncodedBodyWriter.java
/** * Creates HTTP body form url encoded from the ParameterMap * @return the HTTP body form url encoded *///from www .j a va 2 s . c om public String createBody() { List<String> allParameters = parameterMap.entrySet().stream() .flatMap(e -> getParametersUrlEncoded(e.getKey(), e.getValue())).collect(Collectors.toList()); return StringUtils.join(allParameters, "&"); }
From source file:org.homiefund.test.config.SecurityConextPrincipalFactory.java
@Override public SecurityContext createSecurityContext(WithUser withUser) { SecurityContext context = SecurityContextHolder.createEmptyContext(); UserDTO user = new UserDTO(); user.setId(withUser.id());//from w w w .j av a 2 s . c om user.setHomes(Stream.of(withUser.homes()).map(h -> { HomeDTO home = new HomeDTO(); home.setId(h.id()); return home; }).collect(Collectors.toList())); Authentication auth = new UsernamePasswordAuthenticationToken(user, user.getPassword(), user.getAuthorities()); context.setAuthentication(auth); return context; }
From source file:com.netflix.spinnaker.orca.clouddriver.tasks.pipeline.UpdateMigratedPipelineTask.java
@Override public TaskResult execute(Stage stage) { Map<String, Object> context = stage.getContext(); Map<String, Object> pipeline = (Map<String, Object>) context.get("source.pipeline"); List<Map> stages = (List<Map>) pipeline.getOrDefault("stages", new ArrayList<>()); List<Map> katoTasks = (List<Map>) context.get("kato.tasks"); List<Map> resultObjects = (List<Map>) katoTasks.get(0).get("resultObjects"); List<Map> replacements = new ArrayList<>( resultObjects.stream().map(o -> (Map) o.get("cluster")).collect(Collectors.toList())); stages.forEach(s -> PipelineClusterExtractor.getExtractor(s, extractors) .ifPresent(e -> e.updateStageClusters(s, replacements))); String newName = (String) context.getOrDefault("newPipelineName", pipeline.get("name") + " - migrated"); pipeline.put("name", newName); pipeline.remove("id"); List<Map> triggers = (List<Map>) pipeline.getOrDefault("triggers", new ArrayList<>()); triggers.forEach(t -> t.put("enabled", false)); front50Service.savePipeline(pipeline); String application = (String) context.get("application"); Optional<Map<String, Object>> newPipeline = front50Service.getPipelines(application).stream() .filter(p -> newName.equals(p.get("name"))).findFirst(); if (!newPipeline.isPresent()) { Map<String, Object> outputs = new HashMap<>(); outputs.put("exception", "Pipeline migration was successful but could not find new pipeline with name " + newName); return new DefaultTaskResult(ExecutionStatus.TERMINAL, outputs); }//from ww w .j av a 2 s . c o m Map<String, Object> outputs = new HashMap<>(); outputs.put("newPipelineId", newPipeline.get().get("id")); return new DefaultTaskResult(ExecutionStatus.SUCCEEDED, outputs); }
From source file:uk.co.flax.biosolr.ontology.core.ols.graph.Graph.java
/** * Look up all edges, optionally including child relationships. * @param iri the IRI of the source of the relationship. * @param includeParentRelations <code>true</code> if parent nodes * should be included in the results. * @return a collection of {@link Edge} entries for the graph. Never * <code>null</code>./* ww w . ja va2 s . c o m*/ */ public Collection<Edge> getEdgesBySource(String iri, boolean includeParentRelations) { Collection<Edge> ret; if (edges != null) { ret = edges.stream().filter(e -> iri.equals(e.getSource())) .filter(e -> includeParentRelations || !e.isChildRelation()).collect(Collectors.toList()); } else { ret = Collections.emptyList(); } return ret; }
From source file:io.wcm.devops.conga.plugins.aem.tooling.crypto.cli.CryptoKeysTest.java
private void assetFiles(Stream<File> filesStream) { List<File> files = filesStream.collect(Collectors.toList()); assertEquals(2, files.size());//w w w. j a v a 2 s .c om assertTrue(files.get(0).exists()); assertEquals("master", files.get(0).getName()); assertTrue(files.get(1).exists()); assertEquals("hmac", files.get(1).getName()); }
From source file:org.obiba.mica.network.search.EsPublishedNetworkService.java
@Nullable @Override/*from w w w . j a v a 2s . c o m*/ protected Searcher.IdFilter getAccessibleIdFilter() { if (isOpenAccess()) return null; return new Searcher.IdFilter() { @Override public Collection<String> getValues() { return networkService.findPublishedIds().stream() .filter(s -> subjectAclService.isAccessible("/network", s)).collect(Collectors.toList()); } }; }
From source file:org.obiba.mica.project.search.EsPublishedProjectService.java
@Nullable @Override//from ww w . ja v a 2s .c o m protected Searcher.IdFilter getAccessibleIdFilter() { if (isOpenAccess()) return null; return new Searcher.IdFilter() { @Override public Collection<String> getValues() { return projectService.findPublishedIds().stream() .filter(s -> subjectAclService.isAccessible("/project", s)).collect(Collectors.toList()); } }; }
From source file:documents.DocumentProvider.java
public List<Document> getDocuments(long num) { return docsAvailable.entrySet().stream().filter(e -> e.getValue() == 0).limit(num).map(m -> { docsAvailable.put(m.getKey(), 1); // Tag the entries as being read return m; }).map(Map.Entry::getKey).collect(Collectors.toList()); }
From source file:org.obiba.mica.security.rest.SubjectAclResource.java
@GET public List<AclDto> get() { checkPermission();/*ww w. java2 s .c o m*/ return subjectAclService.findByResourceInstance(resource, instance).stream() .map(a -> AclDto.newBuilder().setType(a.getType().name()).setPrincipal(a.getPrincipal()) .setResource(resource).setRole(PermissionsUtils.asRole(a.getActions())) .setInstance(FileUtils.decode(instance)).build()) .collect(Collectors.toList()); }
From source file:com.netflix.spinnaker.igor.artifacts.ArtifactExtractor.java
public List<Artifact> extractArtifacts(GenericBuild build) { final String messageString; try {//from w w w .j a v a2 s . co m messageString = objectMapper.writeValueAsString(build); } catch (JsonProcessingException e) { log.error("Error processing JSON: {}", e); return Collections.emptyList(); } return getArtifactTemplates(build).stream() .flatMap(template -> processTemplate(template, messageString).stream()) .collect(Collectors.toList()); }