List of usage examples for java.util List forEach
default void forEach(Consumer<? super T> action)
From source file:io.wcm.devops.conga.generator.FileGenerator.java
private void applyPostProcessor(FileContext fileItem, PostProcessorPlugin plugin) { log.info(" Post-process {} for file {}", plugin.getName(), getFilenameForLog(fileItem)); List<FileContext> processedFiles = plugin.apply(fileItem, postProcessorContext); // validate processed files if (processedFiles != null) { processedFiles.forEach(processedFile -> applyFileHeader(processedFile, (String) null)); processedFiles.forEach(processedFile -> applyValidation(processedFile, ImmutableList.of())); }/*from w w w .j av a 2 s. c om*/ }
From source file:edu.usu.sdl.opencatalog.web.action.TestAction.java
@HandlesEvent("ConvertData") public Resolution convertData() throws IOException { List<OldAsset> assets = objectMapper.readValue( new File("C:\\development\\storefront\\source\\old_data\\assets.json"), new TypeReference<List<OldAsset>>() { });//from w ww . j a v a 2 s. c om List<Asset> newAssets = new ArrayList<>(); assets.forEach(oldAsset -> { Asset asset = new Asset(); asset.setId(oldAsset.getId()); asset.setName(oldAsset.getTitle()); asset.setDescription(oldAsset.getDescription()); asset.setOwner(oldAsset.getOrganization()); asset.setShortDescription( oldAsset.getDescription().substring(0, oldAsset.getDescription().indexOf("."))); asset.getStats().setAverageRating(oldAsset.getAvgRate()); asset.getStats().setComments(oldAsset.getTotalComments()); asset.getStats().setNumberRatings(oldAsset.getTotalVotes()); Map<String, String> typeMap = new HashMap<>(); typeMap.put("4", "WIDGET"); typeMap.put("9", "APPS"); typeMap.put("10", "REFDOCS"); typeMap.put("18", "SOFTLIB"); String type = "TOOLS"; String foundType = typeMap.get("" + oldAsset.getTypes().getId()); if (StringUtils.isNotBlank(foundType)) { type = foundType; } asset.setType(type); asset.setConformanceState(oldAsset.getState().getTitle()); oldAsset.getCategories().forEach(cat -> { AssetCategory category = new AssetCategory(); category.setDesc(cat.getTitle()); asset.getCategories().add(category); }); newAssets.add(asset); }); return streamResults(newAssets); }
From source file:az.kanan.batterystat.frame.MainFrame.java
private DefaultCategoryDataset createDataset() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); List<Battery> baterryTrackList = queriesImpl.getTrackedInfo(jDateChooser1.getDate(), jDateChooser2.getDate());/*from w w w. j a v a 2 s .c o m*/ baterryTrackList.forEach((baterry) -> { dataset.addValue(baterry.getBatteryLife(), "percent", baterry.getDate()); }); return dataset; }
From source file:co.rsk.net.discovery.PeerExplorer.java
private void askForMoreNodes(List<Node> closestNodes) { List<Node> nodesNotQueriedYet = closestNodes.stream() .filter(n -> !this.nodesAsked.containsKey(n.getHexId())).collect(Collectors.toList()); List<Node> nodesToAsk = getRandomizeLimitedList(nodesNotQueriedYet, MAX_NODES_TO_ASK, 5); nodesToAsk.forEach(this::sendFindNode); }
From source file:com.tascape.qa.th.android.driver.AdbDevice.java
public String getAppVersion(String packageName) throws IOException, EntityDriverException { List<String> res = this.adb.shell(Lists.newArrayList("dumpsys", "package", packageName)); res.forEach(l -> LOG.debug(l)); String versionName = ""; String versionCode = ""; for (int i = 0, j = res.size(); i < j; i++) { String line = res.get(i); if (line.contains("versionName")) { versionName = line.trim().split("=")[1]; } else if (line.contains("versionCode")) { versionCode = line.trim().split(" ")[0].split("=")[1]; }/*ww w.ja v a2 s . co m*/ if (!versionName.isEmpty() && !versionCode.isEmpty()) { break; } } if (versionName.isEmpty() || versionCode.isEmpty()) { throw new EntityDriverException("Cannot find app version"); } return versionName + "-" + versionCode; }
From source file:com.watchrabbit.scanner.supervisor.strategy.BasicFormDataGenerator.java
private void fillEmailFields(Form form, List<String> words) { List<Field> emailInputs = form.getFields().stream().filter(field -> !field.isFilled()) .filter(field -> generatorService.isEmail(getDescription(field))).collect(toList()); if (!emailInputs.isEmpty()) { FieldValue email = generatorService.generateValue(getDescription(emailInputs.get(0)), words); emailInputs.forEach(field -> field.setValue(email.getValue())); emailInputs.forEach(field -> field.setFormality(email.getFormality())); }/*from w w w . j a v a2 s . c o m*/ }
From source file:com.globocom.grou.report.ts.opentsdb.OpenTSDBClient.java
private ArrayList<HashMap<String, Object>> doRequest(long testCreated, long testLastModified, List<Query> queries) { final ArrayList<HashMap<String, Object>> listOfResult = new ArrayList<>(); queries.forEach(query -> { String aggr = query.aggregator; String ds = query.downsample; ObjectNode jBody = JsonNodeFactory.instance.objectNode(); jBody.set("queries", mapper.valueToTree(Collections.singleton(query))); jBody.put("start", testCreated); jBody.put("end", testLastModified); String bodyRequest = jBody.toString(); Request requestQuery = HTTP_CLIENT.preparePost(OPENTSDB_URL + "/api/query").setBody(bodyRequest) .setHeader(CONTENT_TYPE, APPLICATION_JSON.toString()).build(); try {/*from w w w . j a v a 2 s . c om*/ Response response = HTTP_CLIENT.executeRequest(requestQuery).get(); String body = response.getResponseBody(); ArrayList<HashMap<String, Object>> resultMap = mapper.readValue(body, typeRef); for (HashMap<String, Object> result : resultMap) result.put("aggr", aggr); resultMap.forEach(h -> listOfResult.add(renameMetricKey(h, aggr, ds))); } catch (InterruptedException | ExecutionException | IOException e) { if (LOGGER.isDebugEnabled()) LOGGER.error(e.getMessage(), e); } }); return listOfResult; }
From source file:org.apache.solr.metrics.reporters.solr.SolrClusterReporter.java
public void setReport(List<Map> reportConfig) { if (reportConfig == null || reportConfig.isEmpty()) { return;//w w w . j av a 2s.co m } reportConfig.forEach(map -> { SolrReporter.Report r = SolrReporter.Report.fromMap(map); if (r != null) { reports.add(r); } }); }
From source file:co.rsk.net.discovery.PeerExplorer.java
private void checkPeersPulse(List<Node> closestNodes) { List<Node> nodesToCheck = this.getRandomizeLimitedList(closestNodes, MAX_NODES_TO_CHECK, 10); nodesToCheck.forEach(node -> sendPing(node.getAddress(), 1, node)); }
From source file:demo.domain.service.MyUserDetailsService.java
@Override @Transactional(readOnly = true)//from w w w . j ava 2 s . c o m public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { Account account = Optional.ofNullable(accountService.selectFindOne(username)) .orElseThrow(() -> new UsernameNotFoundException("?????")); List<UserProjectRoleAuthority> userProjectRoleAuthority = Optional .ofNullable(userProjectRoleAuthorityService.selectFindByUserId(account.getUserId())) .orElseThrow(() -> new UsernameNotFoundException("??????")); List<GrantedAuthority> authorities = new ArrayList<>(); userProjectRoleAuthority.forEach((UserProjectRoleAuthority upra) -> { StringBuilder sb = new StringBuilder(); sb.append(upra.getProjectId()); sb.append("."); sb.append(upra.getRoleId()); sb.append("."); sb.append(upra.getAuthorityId()); authorities.add(new SimpleGrantedAuthority(sb.toString())); }); return new MyUserDetails(account, authorities); }