List of usage examples for java.util List forEach
default void forEach(Consumer<? super T> action)
From source file:main.java.framework.api.MeasurementRepository.java
/** * @param metrics//from w ww. j av a 2 s.c om * @return */ public static Map<String, List<Integer>> getMeasures(List<String> metrics) { Map<String, List<Integer>> metricsMeasures = new HashMap<>(); SonarDbClient client = new SonarDbClient(DataSourceProvider.getDataSource()); metrics.forEach(x -> metricsMeasures.put(x, client.getMeasures(x))); return metricsMeasures; }
From source file:com.dragovorn.dragonbot.api.bot.file.FileManager.java
public static void reloadFiles() { FileManager.config = new File(directory, "config.yml"); FileManager.logs = new File(directory, "logs"); FileManager.plugins = new File(directory, "plugins"); FileManager.updater = new File(directory, "updater.jar"); List<File> toCopy = new ArrayList<>(); toCopy.addAll(pluginAddedFiles);//from w w w . ja v a 2 s .c o m pluginAddedFiles.clear(); toCopy.forEach(file -> { try { if (file.isDirectory()) { FileUtils.copyDirectory(file, new File(directory, file.getName())); } else { FileUtils.copyFile(file, new File(directory, file.getName())); } file.delete(); pluginAddedFiles.add(new File(directory, file.getName())); } catch (IOException exception) { exception.printStackTrace(); } }); }
From source file:com.github.lynxdb.server.core.TimeSerie.java
public static TimeSerie merge(List<TimeSerie> _series) { Assert.notEmpty(_series);/*from w w w.j a v a 2 s. c o m*/ List<SuperIterator> sil = new ArrayList<>(); _series.forEach((TimeSerie t) -> { if (t.hasNext()) { SuperIterator<Entry> si = new SuperIterator<>(t); si.next(); sil.add(si); } }); Map<String, String> tags = new HashMap<>(); tags.putAll(_series.get(0).getTags()); _series.forEach((TimeSerie t) -> { Iterator<Map.Entry<String, String>> i = tags.entrySet().iterator(); while (i.hasNext()) { Map.Entry<String, String> e = i.next(); if (!t.getTags().containsKey(e.getKey()) || !t.getTags().get(e.getKey()).equals(e.getValue())) { i.remove(); } } }); return new TimeSerie(_series.get(0).getName(), tags, new ChainableIterator<Entry>() { @Override public boolean hasNext() { return sil.stream() .anyMatch((superIterator) -> superIterator.hasNext() || superIterator.getCurrent() != null); } @Override public Entry next() { Iterator<SuperIterator> rr = sil.iterator(); while (rr.hasNext()) { if (rr.next().getCurrent() == null) { rr.remove(); } } long max = Long.MIN_VALUE; for (SuperIterator<Entry> r : sil) { max = Long.max(max, r.getCurrent().getTime()); } for (SuperIterator<Entry> r : sil) { if (r.getCurrent().getTime() == max) { r.next(); return r.getPrevious(); } } throw new IllegalStateException("something went wrong"); } }); }
From source file:main.java.framework.api.MeasurementRepository.java
/** * @param metrics/*from w w w . j a va 2 s . c o m*/ * @return */ public static Map<String, List<Integer>> getRecentMeasures(List<String> metrics) { Map<String, List<Integer>> recentMetricsMeasures = new HashMap<>(); SonarDbClient client = new SonarDbClient(DataSourceProvider.getDataSource()); metrics.forEach(x -> recentMetricsMeasures.put(x, client.getRecentMeasures(x))); return recentMetricsMeasures; }
From source file:io.github.swagger2markup.internal.utils.TagUtils.java
/** * Converts the global Tag list into a Map where the tag name is the key and the Tag the value. * Either ordered or as-is, if the comparator is null. * * @param tags the List of tags//from w w w.j a v a 2 s. c o m * @param comparator the comparator to use. * @return the Map of tags. Either ordered or as-is, if the comparator is null. */ public static Map<String, Tag> toSortedMap(List<Tag> tags, Comparator<String> comparator) { Map<String, Tag> sortedMap; if (comparator == null) sortedMap = new LinkedHashMap<>(); else sortedMap = new TreeMap<>(comparator); tags.forEach(tag -> sortedMap.put(tag.getName(), tag)); return sortedMap; }
From source file:jterm.command.Dir.java
@Command(name = "rmdir", minOptions = 1, syntax = "rm [-h] [-r] dirName") public static void rm(List<String> options) { List<String> filesToBeRemoved = new ArrayList<>(); final boolean[] recursivelyDeleteFlag = { false }; options.forEach(option -> { switch (option) { case "-r": recursivelyDeleteFlag[0] = true; break; default:/*w w w.j a va 2s . c o m*/ filesToBeRemoved.add(option); break; } }); filesToBeRemoved.forEach(fileName -> { File file = new File(JTerm.currentDirectory, fileName); if (!file.isFile() && !file.isDirectory()) { JTerm.out.printf(TextColor.ERROR, "%s is not a file or directory%n", fileName); } else if (file.isDirectory()) { if (recursivelyDeleteFlag[0]) { try { FileUtils.deleteDirectory(file); } catch (IOException e) { JTerm.out.printf(TextColor.ERROR, "Error when deleting %s%n", fileName); } } else { JTerm.out.println(TextColor.ERROR, "Attempting to delete a directory. Run the command again with -r."); return; } } file.delete(); }); }
From source file:com.gazbert.bxbot.repository.impl.StrategyConfigRepositoryXmlImpl.java
private static List<StrategyConfig> adaptAllInternalToAllExternalConfig( TradingStrategiesType internalStrategiesConfig) { final List<StrategyConfig> strategyConfigItems = new ArrayList<>(); final List<StrategyType> internalStrategyConfigItems = internalStrategiesConfig.getStrategies(); internalStrategyConfigItems.forEach((item) -> { final StrategyConfig strategyConfig = new StrategyConfig(); strategyConfig.setId(item.getId()); strategyConfig.setLabel(item.getLabel()); strategyConfig.setDescription(item.getDescription()); strategyConfig.setClassName(item.getClassName()); item.getConfiguration().getConfigItem().forEach(internalConfigItem -> strategyConfig.getConfigItems() .put(internalConfigItem.getName(), internalConfigItem.getValue())); strategyConfigItems.add(strategyConfig); });//from w w w. j ava2s. c o m return strategyConfigItems; }
From source file:com.baidu.rigel.biplatform.ac.util.JsonUnSeriallizableUtils.java
/** * ??/*from w w w.j a v a2 s . c o m*/ * * @param listFields ? * @param parentField * @param parentLevelField */ public static void setHeadFieldParent(List<HeadField> listFields, HeadField parentField, HeadField parentLevelField) { if (CollectionUtils.isNotEmpty(listFields)) { listFields.forEach((field) -> { field.setParent(parentField); field.setParentLevelField(parentLevelField); // ?? setHeadFieldParent(field.getChildren(), field, parentLevelField); // ??null setHeadFieldParent(field.getNodeList(), null, field); }); } }
From source file:org.sahli.asciidoc.confluence.publisher.maven.plugin.AsciidocConfluenceConverter.java
private static void buildPageTree(List<ConfluencePageMetadata> parentPages, MultiValueMap<String, ConfluencePageMetadata> confluencePageMetadataRegistry, String generatedDocOutputPath) { parentPages.forEach(page -> { String parentFolder = removeExtension( Paths.get(generatedDocOutputPath, page.getContentFilePath()).toFile().getAbsolutePath()); List<ConfluencePageMetadata> childPages = confluencePageMetadataRegistry.get(parentFolder); if (childPages != null) { page.getChildren().addAll(childPages); buildPageTree(childPages, confluencePageMetadataRegistry, generatedDocOutputPath); }/*from w w w .j a va 2 s .c om*/ }); }
From source file:edu.berkeley.nwbqueryengine.util.ValuesUtil.java
public static List<NwbResult> removeDatasetWithDuplicitPath(List<NwbResult> first, List<NwbResult> second) { List<NwbResult> results = new LinkedList<>(); List<Wrapper> firstWrapper = new LinkedList<>(); List<Wrapper> secondWrapper = new LinkedList<>(); first.forEach(item -> firstWrapper.add(new Wrapper(getPathWithoutDatasetName(item), item))); second.forEach(item -> secondWrapper.add(new Wrapper(getPathWithoutDatasetName(item), item))); firstWrapper.forEach(item -> {//from ww w. j a v a2 s .com if (secondWrapper.contains(item)) { results.add(item.getResult()); } }); secondWrapper.forEach(item -> { if (firstWrapper.contains(item)) { results.add(item.getResult()); } }); return results; }