List of usage examples for java.util TreeSet stream
default Stream<E> stream()
From source file:org.apache.geode.BundledJarsJUnitTest.java
/** * Find all of the jars bundled with the project. Key is the name of the jar, value is the path. */// ww w . ja va2 s . com private TreeMap<String, String> getBundledJars() { File geodeHomeDirectory = new File(GEODE_HOME); assertTrue("Please set the GEODE_HOME environment variable to the product installation directory.", geodeHomeDirectory.isDirectory()); Collection<File> jars = FileUtils.listFiles(geodeHomeDirectory, new String[] { "jar" }, true); TreeMap<String, String> sortedJars = new TreeMap<>(); jars.forEach(jar -> sortedJars.put(jar.getName(), jar.getPath())); Collection<File> wars = FileUtils.listFiles(geodeHomeDirectory, new String[] { "war" }, true); TreeSet<File> sortedWars = new TreeSet<>(wars); sortedWars.stream().flatMap(BundledJarsJUnitTest::extractJarNames) .forEach(jar -> sortedJars.put(jar.getName(), jar.getPath())); sortedJars.keySet().removeIf(s -> s.startsWith("geode")); return sortedJars; }
From source file:org.oneandone.gitter.out.CSVConsumer.java
public void consume(Map<String, Map<?, ?>> perProjectResults, Function<Object, String> keyFormatter, Function<Object, String> valueFormatter, Supplier<Object> nullValue) throws IOException { List<String> projects = perProjectResults.keySet().stream().sorted().collect(Collectors.toList()); List<String> headers = new ArrayList<>(projects); headers.add(0, "Key"); CSVPrinter printer = CSVFormat.EXCEL.withHeader(headers.toArray(new String[0])).print(p); Set<Object> keys = perProjectResults.values().stream().flatMap(m -> m.keySet().stream()) .collect(Collectors.toSet()); TreeSet<Object> sortedKeys = new TreeSet<>(keys); sortedKeys.stream().forEachOrdered(key -> { List<String> values = new ArrayList<>(); values.add(keyFormatter.apply(key)); projects.forEach(project -> { Object obj = perProjectResults.get(project).get(key); if (obj == null) { obj = nullValue.get();// w ww. j a v a2 s .c om } Objects.requireNonNull(obj, () -> "Object at key " + keyFormatter.apply(key) + " for project " + project + " is null"); values.add(obj != null ? valueFormatter.apply(obj) : "<null>"); }); try { printer.printRecord(values); } catch (IOException ex) { throw new RuntimeException(ex); } }); }
From source file:pl.otros.logview.filter.MultipleSelectionFilter.java
private void reloadFilterSet() { LogData[] ld = collector.getLogData(); TreeSet<String> sortedFilterItems = new TreeSet<>(String::compareToIgnoreCase); for (LogData logData : ld) { sortedFilterItems.add(getFilteredString(logData)); }//from www .j a v a2s .co m sortedFilterItems.stream().filter(sortedItem -> !listModel.contains(sortedItem)) .forEach(sortedItem -> listModel.add(listModel.getSize(), sortedItem)); setItemToFilter(selectedItems.toArray(new String[selectedItems.size()])); }