List of usage examples for java.util.stream Collectors toCollection
public static <T, C extends Collection<T>> Collector<T, ?, C> toCollection(Supplier<C> collectionFactory)
From source file:eu.ggnet.dwoss.report.assist.ReportUtil.java
/** * Returns a Set of all Warrenty Positions in the Collection that is given to the method. * <p>// w ww . j ava 2s . c o m * A Warranty is in the Set of Reportable Warranty if * <ul> * <li>SingleRefence from Type {@link SingleReferenceType#WARRANTY} is not null</li> * <li>SingleReferenced Unit is in the reportable Amount of ReportLines</li> * <li>Reporting Date is after the from Parameter and before the till Parameter</li> * </ul> * <p> * @param warrentyLines all unreported Reportlines that represent warrenty. * @param unitLines all ReportLine's that are already in amount of Reportlines which should be reported. * @return all Warrentys which can be reported in this report. */ public static NavigableSet<ReportLine> filterWarrenty(Collection<ReportLine> warrentyLines, Collection<ReportLine> unitLines) { L.info("Warranties in filter: {}", warrentyLines); return warrentyLines.stream() .filter((t) -> t != null && t.getReference(WARRANTY) != null && (unitLines.contains(t.getReference(WARRANTY)) || !t.getReference(WARRANTY).getReports().isEmpty())) .collect(Collectors.toCollection(() -> new TreeSet<ReportLine>())); }
From source file:org.dllearner.core.AnnComponentManager.java
/** * Returns a list of all available components in this instance * of <code>ComponentManager</code>. * @return the components A list of component classes available in this * instance of <code>ComponentManager</code>. *//*w w w .j a va2s. c om*/ public SortedSet<String> getComponentStrings() { SortedSet<String> result = getComponents().stream().map(AnnComponentManager::getShortName) .collect(Collectors.toCollection(TreeSet::new)); return result; }
From source file:com.netflix.imfutility.itunes.audio.AudioMapXmlProvider.java
/** * Gets array of additional audio tracks numbers by order. * * @return array of additional audio tracks numbers by order *//*from w w w . ja v a2 s . co m*/ public ArrayList<Integer> getAdditionalAudioTracks() { return alternativesAudio.stream().map(AudioOption::size).collect(Collectors.toCollection(ArrayList::new)); }
From source file:org.dllearner.core.AnnComponentManager.java
/** * Get registered components which are of the specified type. * * @param type The super type./*from ww w. ja v a2 s . com*/ * @return All sub classes of type. */ public SortedSet<String> getComponentStringsOfType(Class type) { SortedSet<String> result = getComponentsOfType(type).stream().map(AnnComponentManager::getShortName) .collect(Collectors.toCollection(TreeSet::new)); return result; }
From source file:ddf.security.SubjectUtils.java
private static SortedSet<String> getAttributeValues(org.opensaml.saml.saml2.core.Attribute attribute) { return attribute.getAttributeValues().stream().filter(XSString.class::isInstance).map(XSString.class::cast) .map(XSString::getValue).collect(Collectors.toCollection(TreeSet::new)); }
From source file:de.bund.bfr.knime.gis.views.canvas.CanvasUtils.java
public static Set<String> getElementIds(Collection<? extends Element> elements) { return elements.stream().map(e -> e.getId()).collect(Collectors.toCollection(LinkedHashSet::new)); }
From source file:com.netflix.imfutility.itunes.audio.AudioMapXmlProvider.java
/** * Gets array of additional audio file names by order. * * @return array of additional audio file names by order *//* w w w. j ava 2s . co m*/ public ArrayList<String> getAdditionalAudioFileNames() { return alternativesAudio.stream().map(AudioOption::getFileName) .collect(Collectors.toCollection(ArrayList::new)); }
From source file:org.onosproject.intentperf.IntentPerfInstaller.java
private List<NodeId> getNeighbors() { List<NodeId> nodes = clusterService.getNodes().stream().map(ControllerNode::id) .collect(Collectors.toCollection(ArrayList::new)); // sort neighbors by id Collections.sort(nodes, (node1, node2) -> node1.toString().compareTo(node2.toString())); // rotate the local node to index 0 Collections.rotate(nodes, -1 * nodes.indexOf(clusterService.getLocalNode().id())); log.debug("neighbors (raw): {}", nodes); //TODO remove // generate the sub-list that will contain local node and selected neighbors nodes = nodes.subList(0, numNeighbors + 1); log.debug("neighbors: {}", nodes); //TODO remove return nodes; }
From source file:de.bund.bfr.knime.gis.views.canvas.CanvasUtils.java
public static <T extends Element> Set<T> getElementsById(Collection<T> elements, Set<String> ids) { return elements.stream().filter(e -> ids.contains(e.getId())) .collect(Collectors.toCollection(LinkedHashSet::new)); }
From source file:com.steelbridgelabs.oss.neo4j.structure.Neo4JGraph.java
public Iterator<Edge> edges(Statement statement) { Objects.requireNonNull(statement, "statement cannot be null"); // get current session Neo4JSession session = currentSession(); // transaction should be ready for io operations transaction.readWrite();/*from w w w . ja v a 2 s . c o m*/ // execute statement StatementResult result = session.executeStatement(statement); // find edges Iterator<Edge> iterator = session.edges(result).collect(Collectors.toCollection(LinkedList::new)) .iterator(); // process summary (query has been already consumed by collect) ResultSummaryLogger.log(result.consume()); // return iterator return iterator; }