List of usage examples for java.util.stream Collectors toList
public static <T> Collector<T, ?, List<T>> toList()
From source file:de.msg.repository.RouteRepositoryImpl.java
@Override public Iterable<Route> findByDeparture(String departure) { return StreamSupport.stream(driver.getRouteList().spliterator(), false).filter(new Predicate<Route>() { @Override/*from w ww. ja va 2s .c om*/ public boolean test(Route route) { return route.getDeparture().equals(departure); } }).collect(Collectors.toList()); }
From source file:com.github.horrorho.inflatabledonkey.cloudkitty.operations.ZoneRetrieveRequestOperations.java
static List<RequestOperation> operations(Collection<String> zones, String cloudKitUserId) { return zones.stream().map(u -> operation(u, cloudKitUserId)).collect(Collectors.toList()); }
From source file:com.intuit.quickbase.MergeStatService.java
public void retrieveCountryPopulationList() { DBStatService dbStatService = new DBStatService(); List<Pair<String, Integer>> dbList = dbStatService.GetCountryPopulations(); ConcreteStatService conStatService = new ConcreteStatService(); List<Pair<String, Integer>> apiList = conStatService.GetCountryPopulations(); //Use of Predicate Interface Predicate<Pair<String, Integer>> pred = (pair) -> pair != null; if (apiList != null) { // Converting the keys of each element in the API list to lowercase List<Pair<String, Integer>> modifiedAPIList = apiList.stream().filter(pred) .map(p -> new ImmutablePair<String, Integer>(p.getKey().toLowerCase(), p.getValue())) .collect(Collectors.toList()); //modifiedAPIList.forEach(pair -> System.out.println("key: " + pair.getLeft() + ": value: " + pair.getRight())); if (dbList != null) { // Merge two list and remove duplicates Collection<Pair<String, Integer>> result = Stream.concat(dbList.stream(), modifiedAPIList.stream()) .filter(pred)//from w w w . j av a 2 s . co m .collect(Collectors.toMap(Pair::getLeft, p -> p, (p, q) -> p, LinkedHashMap::new)).values(); // Need to Convert collection to List List<Pair<String, Integer>> merge = new ArrayList<>(result); merge.forEach(pair -> System.out.println("key: " + pair.getKey() + ": value: " + pair.getValue())); } else { System.out.println("Country list retrieved form database is empty"); } } else { System.out.println("Country list retrieved form API is empty"); } // if(apiList != null) { // Iterator itr = apiList.iterator(); // for(Pair<String, Integer> pair : apiList){ // //System.out.println("key: " + pair.getLeft() + ": value: " + pair.getRight()); // } // } }
From source file:com.microsoft.azure.hdinsight.spark.jobs.YarnRestUtil.java
private static List<App> getSparkAppFromYarn(@NotNull final IClusterDetail clusterDetail) throws IOException, HDIException { final HttpEntity entity = getYarnRestEntity(clusterDetail, "cluster/apps"); Optional<YarnApplicationResponse> allApps = ObjectConvertUtils.convertEntityToObject(entity, YarnApplicationResponse.class); return allApps.orElse(YarnApplicationResponse.EMPTY).getAllApplication().orElse(App.EMPTY_LIST).stream() .filter(app -> app.isLivyJob()).collect(Collectors.toList()); }
From source file:alfio.model.TicketFieldConfigurationAndDescription.java
public List<Pair<String, String>> getTranslatedRestrictedValue() { Map<String, String> description = ticketFieldDescription.getRestrictedValuesDescription(); return ticketFieldConfiguration.getRestrictedValues().stream() .map(val -> Pair.of(val, description.getOrDefault(val, "MISSING_DESCRIPTION"))) .collect(Collectors.toList()); }
From source file:com.liferay.ide.core.util.FileListing.java
public static List<IPath> getFileListing(File dir, String fileType) { Collection<File> files = FileUtils.listFiles(dir, new String[] { fileType }, true); Stream<File> stream = files.stream(); return stream.filter(file -> file.exists()).map(file -> new Path(file.getPath())) .collect(Collectors.toList()); }
From source file:com.uber.hoodie.common.util.CompactionUtils.java
/** * Generate compaction operation from file-slice * * @param partitionPath Partition path * @param fileSlice File Slice * @param metricsCaptureFunction Metrics Capture function * @return Compaction Operation//from w ww. ja v a2 s . c o m */ public static HoodieCompactionOperation buildFromFileSlice(String partitionPath, FileSlice fileSlice, Optional<Function<Pair<String, FileSlice>, Map<String, Double>>> metricsCaptureFunction) { HoodieCompactionOperation.Builder builder = HoodieCompactionOperation.newBuilder(); builder.setPartitionPath(partitionPath); builder.setFileId(fileSlice.getFileId()); builder.setBaseInstantTime(fileSlice.getBaseInstantTime()); builder.setDeltaFilePaths( fileSlice.getLogFiles().map(lf -> lf.getPath().toString()).collect(Collectors.toList())); if (fileSlice.getDataFile().isPresent()) { builder.setDataFilePath(fileSlice.getDataFile().get().getPath()); } if (metricsCaptureFunction.isPresent()) { builder.setMetrics(metricsCaptureFunction.get().apply(Pair.of(partitionPath, fileSlice))); } return builder.build(); }
From source file:org.jboss.pnc.rest.provider.EnvironmentProvider.java
public List<EnvironmentRest> getAll(Integer pageIndex, Integer pageSize, String sortingRsql, String query) { RSQLPredicate filteringCriteria = RSQLPredicateProducer.fromRSQL(Environment.class, query); Pageable paging = RSQLPageLimitAndSortingProducer.fromRSQL(pageSize, pageIndex, sortingRsql); return nullableStreamOf(environmentRepository.findAll(filteringCriteria.get(), paging)).map(toRestModel()) .collect(Collectors.toList()); }
From source file:hd3gtv.embddb.MainClass.java
private static List<InetSocketAddress> importConf(PoolManager poolmanager, Properties conf, int default_port) throws Exception { if (conf.containsKey("hosts") == false) { throw new NullPointerException("No hosts in configuration"); }/*from w ww . j a v a2 s .c o m*/ String hosts = conf.getProperty("hosts"); return Arrays.asList(hosts.split(" ")).stream().map(addr -> { if (addr.isEmpty() == false) { log.debug("Found host in configuration: " + addr); return new InetSocketAddress(addr, default_port); } else { return null; } }).filter(addr -> { return addr != null; }).collect(Collectors.toList()); }
From source file:com.github.rutledgepaulv.qbuilders.visitors.MongoVisitor.java
@Override protected Criteria visit(AndNode node) { Criteria criteria = new Criteria(); List<Criteria> children = node.getChildren().stream().map(this::visitAny).collect(Collectors.toList()); return criteria.andOperator(children.toArray(new Criteria[children.size()])); }