List of usage examples for java.util.stream Collectors toSet
public static <T> Collector<T, ?, Set<T>> toSet()
From source file:net.fabricmc.loader.launch.MixinLoader.java
public Set<String> getServerMixinConfigs() { return mods.stream().map(ModContainer::getInfo).map(ModInfo::getMixins).map(ModInfo.Mixins::getServer) .filter(s -> s != null && !s.isEmpty()).collect(Collectors.toSet()); }
From source file:com.netflix.spinnaker.echo.artifacts.GitHubArtifactExtractor.java
@Override public List<Artifact> getArtifacts(String source, Map payload) { PushEvent pushEvent = objectMapper.convertValue(payload, PushEvent.class); String sha = pushEvent.after; Set<String> affectedFiles = pushEvent.commits.stream().map(c -> { List<String> fs = new ArrayList<>(); fs.addAll(c.added);/*from w ww.j a va2s . c o m*/ fs.addAll(c.modified); return fs; }).flatMap(Collection::stream).collect(Collectors.toSet()); return affectedFiles.stream() .map(f -> Artifact.builder().name(f).version(sha).type("github/file") .reference(pushEvent.repository.contentsUrl.replace("{+path}", f)).build()) .collect(Collectors.toList()); }
From source file:io.gravitee.repository.redis.management.RedisPageRepository.java
@Override public Collection<Page> findByApi(String apiId) throws TechnicalException { return pageRedisRepository.findByApi(apiId).stream().map(this::convert).collect(Collectors.toSet()); }
From source file:com.civprod.writerstoolbox.testarea.UnsupervisedDiscourseSegmentation.java
public static double cosineSimilarityStemmedAndFiltered(Counter<String> countA, Counter<String> countB) { Set<String> allWords = countA.keySet().parallelStream() .filter((String curKey) -> countB.keySet().contains(curKey)).collect(Collectors.toSet()); double dotProduct = allWords.parallelStream() .mapToDouble((String curKey) -> countA.getCount(curKey) * countB.getCount(curKey)).sum(); double sqrtOfSumA = Math .pow(countA.keySet().parallelStream().mapToDouble((String curKey) -> countA.getCount(curKey)) .map((double curValue) -> curValue * curValue).sum(), .5); double sqrtOfSumB = Math .pow(countB.keySet().parallelStream().mapToDouble((String curKey) -> countB.getCount(curKey)) .map((double curValue) -> curValue * curValue).sum(), .5); return dotProduct / (sqrtOfSumA * sqrtOfSumB); }
From source file:eu.itesla_project.offline.tools.CreateOfflineWorkflowTool.java
@Override public void run(CommandLine line) throws Exception { String workflowId = line.getOptionValue("workflow"); Set<Country> countries = line.hasOption("base-case-countries") ? Arrays.stream(line.getOptionValue("base-case-countries").split(",")).map(Country::valueOf) .collect(Collectors.toSet()) : getDefaultParameters().getCountries(); DateTime baseCaseDate = line.hasOption("base-case-date") ? DateTime.parse(line.getOptionValue("base-case-date")) : getDefaultParameters().getBaseCaseDate(); Interval histoInterval = line.hasOption("history-interval") ? Interval.parse(line.getOptionValue("history-interval")) : getDefaultParameters().getHistoInterval(); boolean generationSampled = line.hasOption("generation-sampled") || getDefaultParameters().isGenerationSampled(); boolean boundariesSampled = line.hasOption("boundaries-sampled") || getDefaultParameters().isBoundariesSampled(); boolean initTopo = line.hasOption("topo-init") || getDefaultParameters().isInitTopo(); double correlationThreshold = line.hasOption("correlation-threshold") ? Double.parseDouble(line.getOptionValue("correlation-threshold")) : getDefaultParameters().getCorrelationThreshold(); double probabilityThreshold = line.hasOption("probability-threshold") ? Double.parseDouble(line.getOptionValue("probability-threshold")) : getDefaultParameters().getProbabilityThreshold(); boolean loadFlowTransformerVoltageControlOn = line.hasOption("loadflow-transformer-voltage-control-on") || getDefaultParameters().isLoadFlowTransformerVoltageControlOn(); boolean simplifiedWorkflow = line.hasOption("simplified-workflow") || getDefaultParameters().isSimplifiedWorkflow(); boolean mergeOptimized = line.hasOption("merge-optimized") || getDefaultParameters().isMergeOptimized(); Set<Country> attributesCountryFilter = line.hasOption("attributes-country-filter") ? Arrays.stream(line.getOptionValue("attributes-country-filter").split(",")).map(Country::valueOf) .collect(Collectors.toSet()) : getDefaultParameters().getAttributesCountryFilter(); int attributesMinBaseVoltageFilter = line.hasOption("attributes-min-base-voltage-filter") ? Integer.parseInt(line.getOptionValue("attributes-min-base-voltage-filter")) : getDefaultParameters().getAttributesMinBaseVoltageFilter(); OfflineWorkflowCreationParameters parameters = new OfflineWorkflowCreationParameters(countries, baseCaseDate, histoInterval, generationSampled, boundariesSampled, initTopo, correlationThreshold, probabilityThreshold, loadFlowTransformerVoltageControlOn, simplifiedWorkflow, mergeOptimized, attributesCountryFilter, attributesMinBaseVoltageFilter); parameters.print(System.out); try (OfflineApplication app = new RemoteOfflineApplicationImpl()) { String workflowId2 = app.createWorkflow(workflowId, parameters); System.out.println("offline workflow '" + workflowId2 + "' created"); }//w w w .j a v a 2 s. c om }
From source file:Fasta.java
/**Splits the fasta sequence into a set of every possible //sequence of a certain size which can be found in the sequence including the reverse strand*/// w ww .java 2 s. c o m public static Set<CharSequence> splitFasta(String[] seq, int length) { Set<CharSequence> collect = IntStream.range(0, length).mapToObj(start -> { List<CharSequence> primers = new ArrayList<>(); for (int i = start; i < seq[0].length() - length; i += length) { CharSequence s = seq[0].substring(i, i + length); primers.add(s); } return primers; }).flatMap((i) -> i.stream()).collect(Collectors.toSet()); Set<CharSequence> collect2 = IntStream.range(0, length).mapToObj(start -> { List<CharSequence> primers = new ArrayList<>(); for (int i = start; i < seq[1].length() - length; i += length) { CharSequence s = seq[1].substring(i, i + length); primers.add(s); } return primers; }).flatMap((i) -> i.stream()).collect(Collectors.toSet()); collect.addAll(collect2); return collect; }
From source file:io.gravitee.repository.redis.management.RedisApiRepository.java
@Override public Set<Api> findAll() throws TechnicalException { Set<RedisApi> apis = apiRedisRepository.findAll(); return apis.stream().map(this::convert).collect(Collectors.toSet()); }
From source file:io.gravitee.management.rest.resource.ApiMembersResource.java
@GET @Produces(MediaType.APPLICATION_JSON)//from w w w .j a va 2 s . c o m public Set<MemberEntity> members() { // Check that the API exists apiService.findById(api); return apiService.getMembers(api, null).stream().sorted((o1, o2) -> o1.getUser().compareTo(o2.getUser())) .collect(Collectors.toSet()); }
From source file:io.curly.tagger.listener.EventHandler.java
@Selector("tag.bus") public void handle(Set<TagMessage> message) { log.info("Initiating processor for tag message" + message + " received on Event Bus"); writerCommand.save(message.stream().map(TagMessage::toTag).collect(Collectors.toSet())); }
From source file:io.gravitee.repository.redis.management.internal.impl.ApiRedisRepositoryImpl.java
@Override public Set<RedisApi> find(List<String> apis) { return redisTemplate.opsForHash().multiGet(REDIS_KEY, Collections.unmodifiableCollection(apis)).stream() .map(o -> this.convert(o, RedisApi.class)).collect(Collectors.toSet()); }