List of usage examples for java.util.stream Collectors toList
public static <T> Collector<T, ?, List<T>> toList()
From source file:spring.travel.site.services.news.NewsDigester.java
public List<NewsItem> from(InputStream is) throws IOException { try {//w w w . j a va2 s. c o m Digester digester = new Digester(); digester.setValidating(false); digester.push(new ArrayList<NewsItemDigestible>()); digester.addObjectCreate("rss/channel/item", NewsItemDigestible.class.getName()); digester.addSetNext("rss/channel/item", "add"); digester.addBeanPropertySetter("rss/channel/item/title", "headline"); digester.addBeanPropertySetter("rss/channel/item/description", "standFirst"); digester.addBeanPropertySetter("rss/channel/item/guid", "link"); digester.addObjectCreate("rss/channel/item/media:content", Image.class.getName()); digester.addSetProperties("rss/channel/item/media:content"); digester.addSetNext("rss/channel/item/media:content", "setImage"); List<NewsItemDigestible> items = digester.parse(is); return items.stream().map(n -> n.toNewsItem()).collect(Collectors.toList()); } catch (SAXException se) { throw new IOException("Failed reading rss feed", se); } }
From source file:com.infinitechaos.vpcviewer.web.rest.VpcResource.java
@RequestMapping(value = "/vpcs") public List<VpcDTO> getVpcs(@RequestParam("region") final String region, @RequestParam(value = "bypassCache", required = false) boolean bypassCache) { return vpcService.getVpcsInRegion(region, bypassCache).stream().map(VpcDTO::new) .collect(Collectors.toList()); }
From source file:com.vmware.photon.controller.model.adapters.vsphere.vapi.TaggingClient.java
public List<String> getAttachedTags(ManagedObjectReference ref) throws IOException, RpcException { RpcRequest call = newCall("com.vmware.cis.tagging.tag_association", "list_attached_tags"); bindToSession(call, this.sessionId); call.params.input = newNode();/*from w w w . j a va 2 s .com*/ call.params.input.putObject("STRUCTURE").putObject("operation-input").put("object_id", newDynamicId(ref)); RpcResponse resp = rpc(call); throwIfError("Cannot get tags for object " + VimUtils.convertMoRefToString(ref), resp); return StreamSupport.stream(resp.result.get("output").spliterator(), false).map(JsonNode::asText) .collect(Collectors.toList()); }
From source file:org.ff4j.services.PropertyStoreServices.java
public List<PropertyApiBean> getAllProperties() { List<PropertyApiBean> properties; Map<String, Property<?>> propertyMap = ff4j.getPropertiesStore().readAllProperties(); if (CollectionUtils.isEmpty(propertyMap)) { properties = new ArrayList<>(0); } else {/*from w ww.j a va 2 s . c o m*/ properties = new ArrayList<>(propertyMap.size()); properties.addAll(propertyMap.values().stream().map(PropertyApiBean::new).collect(Collectors.toList())); } return properties; }
From source file:org.obiba.mica.study.rest.DraftIndividualStudiesResource.java
@GET @Path("/individual-studies") @Timed// ww w . ja v a 2 s . c om public List<Mica.StudyDto> list() { return individualStudyService.findAllDraftStudies().stream() .filter(s -> subjectAclService.isPermitted("/draft/individual-study", "VIEW", s.getId())) .sorted((o1, o2) -> o1.getId().compareTo(o2.getId())).map(s -> dtos.asDto(s, true)) .collect(Collectors.toList()); }
From source file:com.miovision.oss.awsbillingtools.parser.DetailedLineItemParser.java
private static List<String> readTags(Iterator<CSVRecord> iterator) { return iterator.hasNext() ? StreamSupport.stream(iterator.next().spliterator(), false).skip(20).collect(Collectors.toList()) : new ArrayList<>(0); }
From source file:org.openlmis.fulfillment.web.shipmentdraft.ShipmentDraftDtoBuilder.java
/** * Create a new list of {@link ShipmentDraftDto} based on data * from {@link ShipmentDraft}.//from ww w. j a va 2s . c o m * * @param shipments collection used to create {@link ShipmentDraftDto} list (can be {@code null}) * @return new list of {@link ShipmentDraftDto}. Empty list if passed argument is {@code null}. */ public List<ShipmentDraftDto> build(Collection<ShipmentDraft> shipments) { if (null == shipments) { return Collections.emptyList(); } return shipments.stream().map(this::export).collect(Collectors.toList()); }
From source file:com.blackducksoftware.integration.hub.detect.workflow.report.OverviewSummarizer.java
public List<OverviewSummaryData> summarize(final List<DetectorEvaluation> evaluations) { final Map<File, List<DetectorEvaluation>> byDirectory = groupByDirectory(evaluations); final List<OverviewSummaryData> summaries = summarize(byDirectory); final List<OverviewSummaryData> sorted = summaries.stream() .sorted((o1, o2) -> filesystemCompare(o1.getDirectory(), o2.getDirectory())) .collect(Collectors.toList()); return sorted; }
From source file:cz.muni.fi.editor.services.api.cmis.RepoTreeServiceImpl.java
@Override public List<RepoTreeEntry> generateTree() { return new ArrayList<>(cmisProxy.getSession().getRootFolder().getFolderTree(-1).stream().map(this::realWalk) .collect(Collectors.toList())); }
From source file:com.tekstosense.opennlp.config.ModelLoaderConfig.java
public static String[] getModels(String[] modelNames) { File dir = new File(Config.getConfiguration().getString(MODELPATH)); LOG.info("Loading Models from... " + dir.getAbsolutePath()); List<String> wildCardPath = Arrays.stream(modelNames).map(model -> { return "en-ner-" + model + "*.bin"; }).collect(Collectors.toList()); FileFilter fileFilter = new WildcardFileFilter(wildCardPath, IOCase.INSENSITIVE); List<String> filePath = Arrays.asList(dir.listFiles(fileFilter)).stream() .map(file -> file.getAbsolutePath()).collect(Collectors.toList()); return filePath.toArray(new String[filePath.size()]); }