List of usage examples for java.util Set stream
default Stream<E> stream()
From source file:co.degraph.server.ui.controllers.TreeController.java
private Collection<TreeNode> artifactToNode(Set<Artifact> artifacts) { return artifacts.stream() .map(artifact -> new TreeNode(artifact.getOrganization(), artifact.getName(), "artifact")) .collect(toSet());//from w w w .ja v a 2s .c o m }
From source file:fi.helsinki.opintoni.service.UserNotificationService.java
private Map<String, CourseDto> getCoursesByRealisationId(Set<CourseDto> courseDtos) { return courseDtos.stream().collect(Collectors.toMap(dto -> dto.realisationId, dto -> dto)); }
From source file:co.degraph.server.ui.controllers.TreeController.java
private Collection<TreeNode> organiztionToNode(Set<Organization> organizations) { return organizations.stream() .map(organization -> new TreeNode(organization.getParent(), organization.getName(), "organization")) .collect(toSet());/*from w ww. j a v a 2s. c om*/ }
From source file:com.act.lcms.db.analysis.AnalysisHelper.java
private static Map<Pair<String, Double>, MS1ScanForWellAndMassCharge> getMultipleMS1s(MS1 ms1, Set<Pair<String, Double>> metlinMasses, String ms1File) throws ParserConfigurationException, IOException, XMLStreamException { // In order for this to sit well with the data model we'll need to ensure the keys are all unique. Set<String> uniqueKeys = new HashSet<>(); metlinMasses.stream().map(Pair::getLeft).forEach(x -> { if (uniqueKeys.contains(x)) { throw new RuntimeException( String.format("Assumption violation: found duplicate metlin mass keys: %s", x)); }/*from ww w. j a v a 2 s .co m*/ uniqueKeys.add(x); }); Iterator<LCMSSpectrum> ms1Iterator = new LCMSNetCDFParser().getIterator(ms1File); Map<Double, List<XZ>> scanLists = new HashMap<>(metlinMasses.size()); // Initialize reading buffers for all of the target masses. metlinMasses.forEach(x -> { if (!scanLists.containsKey(x.getRight())) { scanLists.put(x.getRight(), new ArrayList<>()); } }); // De-dupe by mass in case we have exact duplicates, sort for well-ordered extractions. List<Double> sortedMasses = new ArrayList<>(scanLists.keySet()); /* Note: this operation is O(n * m) where n is the number of (mass, intensity) readings from the scan * and m is the number of mass targets specified. We might be able to get this down to O(m log n), but * we'll save that for once we get this working at all. */ while (ms1Iterator.hasNext()) { LCMSSpectrum timepoint = ms1Iterator.next(); // get all (mz, intensity) at this timepoint List<Pair<Double, Double>> intensities = timepoint.getIntensities(); // for this timepoint, extract each of the ion masses from the METLIN set for (Double ionMz : sortedMasses) { // this time point is valid to look at if its max intensity is around // the mass we care about. So lets first get the max peak location double intensityForMz = ms1.extractMZ(ionMz, intensities); // the above is Pair(mz_extracted, intensity), where mz_extracted = mz // we now add the timepoint val and the intensity to the output XZ intensityAtThisTime = new XZ(timepoint.getTimeVal(), intensityForMz); scanLists.get(ionMz).add(intensityAtThisTime); } } Map<Pair<String, Double>, MS1ScanForWellAndMassCharge> finalResults = new HashMap<>(metlinMasses.size()); /* Note: we might be able to squeeze more performance out of this by computing the * stats once per trace and then storing them. But the time to compute will probably * be dwarfed by the time to extract the data (assuming deduplication was done ahead * of time), so we'll leave it as is for now. */ for (Pair<String, Double> pair : metlinMasses) { String label = pair.getLeft(); Double mz = pair.getRight(); MS1ScanForWellAndMassCharge result = new MS1ScanForWellAndMassCharge(); result.setMetlinIons(Collections.singletonList(label)); result.getIonsToSpectra().put(label, scanLists.get(mz)); ms1.computeAndStorePeakProfile(result, label); // DO NOT use isGoodPeak here. We want positive and negative results alike. // There's only one ion in this scan, so just use its max. Double maxIntensity = result.getMaxIntensityForIon(label); result.setMaxYAxis(maxIntensity); // How/why is this not IonsToMax? Just set it as such for this. result.setIndividualMaxIntensities(Collections.singletonMap(label, maxIntensity)); finalResults.put(pair, result); } return finalResults; }
From source file:com.nextdoor.bender.monitoring.cw.CloudwatchReporter.java
private Collection<Dimension> tagsToDimensions(final Set<Tag> tags) { return tags.stream().map(e -> tagToDim(e.getKey(), e.getValue())).collect(Collectors.toList()); }
From source file:com.netflix.spinnaker.fiat.providers.DefaultServiceAccountProvider.java
@Override public Set<ServiceAccount> getAllRestricted(@NonNull Set<Role> roles) throws ProviderException { List<String> roleNames = roles.stream().map(Role::getName).collect(Collectors.toList()); return getAll().stream().filter(svcAcct -> !svcAcct.getMemberOf().isEmpty()) .filter(svcAcct -> roleNames.containsAll(svcAcct.getMemberOf())).collect(Collectors.toSet()); }
From source file:delfos.dataset.basic.user.UsersDatasetAdapter.java
public UsersDatasetAdapter(Set<User> userCollection) { userCollection.stream().forEach((user) -> add(user)); }
From source file:io.gravitee.repository.redis.management.RedisTagRepository.java
@Override public Set<Tag> findAll() throws TechnicalException { final Set<RedisTag> tags = tagRedisRepository.findAll(); return tags.stream().map(this::convert).collect(Collectors.toSet()); }
From source file:io.gravitee.repository.redis.management.RedisViewRepository.java
@Override public Set<View> findAll() throws TechnicalException { final Set<RedisView> views = viewRedisRepository.findAll(); return views.stream().map(this::convert).collect(Collectors.toSet()); }
From source file:org.trustedanalytics.serviceexposer.checker.CheckerJob.java
public void updateDeletedServiceInstances(String serviceType, Set<CcExtendedServiceInstance> serviceInstances) { Set<String> servicesGuids = serviceInstances.stream() .map(instance -> instance.getMetadata().getGuid().toString()).collect(Collectors.toSet()); for (String serviceInstanceGuid : store.getSurplusServicesGuids(serviceType, servicesGuids)) { credentialsRetriver.deleteServiceInstance(serviceType, UUID.fromString(serviceInstanceGuid)); }//from www .j a v a 2 s .c om }