List of usage examples for java.util.stream Collectors toSet
public static <T> Collector<T, ?, Set<T>> toSet()
From source file:org.openlmis.fulfillment.web.util.BasicOrderDtoBuilder.java
private Map<UUID, ProcessingPeriodDto> getPeriods(List<Order> orders) { Set<UUID> periodIds = orders.stream().map(Order::getProcessingPeriodId).collect(Collectors.toSet()); return periodReferenceDataService.findByIds(periodIds).stream() .collect(Collectors.toMap(BaseDto::getId, Function.identity())); }
From source file:com.act.biointerpretation.networkanalysis.MetabolismNetwork.java
@Override public Set<NetworkNode> getSubstrates(NetworkEdge edge) { return edge.getSubstrates().stream().map(this::getNodeByUID).collect(Collectors.toSet()); }
From source file:com.uber.okbuck.core.util.ProjectUtil.java
public static Map<ComponentIdentifier, ResolvedArtifactResult> downloadSources(Project project, Set<ResolvedArtifactResult> artifacts) { // Download sources if enabled via intellij extension if (!ProjectUtil.getOkBuckExtension(project).getIntellijExtension().downloadSources()) { return new HashMap<>(); }/*from w w w . j a va 2 s.c o m*/ DependencyHandler dependencies = project.getDependencies(); try { Set<ComponentIdentifier> identifiers = artifacts.stream() .filter(artifact -> canHaveSources(artifact.getFile())) .map(artifact -> artifact.getId().getComponentIdentifier()).collect(Collectors.toSet()); @SuppressWarnings("unchecked") Class<? extends Artifact>[] artifactTypesArray = (Class<? extends Artifact>[]) new Class<?>[] { SourcesArtifact.class }; Set<ComponentArtifactsResult> results = dependencies.createArtifactResolutionQuery() .forComponents(identifiers).withArtifacts(JvmLibrary.class, artifactTypesArray).execute() .getResolvedComponents(); // Only has one type. Class<? extends Artifact> type = artifactTypesArray[0]; return results.stream().map(artifactsResult -> artifactsResult.getArtifacts(type)).flatMap(Set::stream) .filter(artifactResult -> artifactResult instanceof ResolvedArtifactResult) .map(artifactResult -> (ResolvedArtifactResult) artifactResult) .filter(artifactResult -> FileUtil.isZipFile(artifactResult.getFile())) .collect(Collectors.toMap(resolvedArtifact -> resolvedArtifact.getId().getComponentIdentifier(), resolvedArtifact -> resolvedArtifact)); } catch (Throwable t) { System.out.println( "Unable to download sources for project " + project.toString() + " with error " + t.toString()); return new HashMap<>(); } }
From source file:org.jboss.tools.jmx.jolokia.JolokiaConnectionWrapper.java
protected J4pClient createJ4pClient() { CustomClientBuilder jb = new CustomClientBuilder() { @Override/*from w w w . j ava2 s. c o m*/ public void clientBuilderAdditions(HttpClientBuilder builder) { Set<Header> defaultHeaders = headers.entrySet().stream() .map(entry -> new BasicHeader(entry.getKey(), entry.getValue())) .collect(Collectors.toSet()); builder.setDefaultHeaders(defaultHeaders); } @Override protected SSLConnectionSocketFactory createDefaultSSLConnectionSocketFactory() { if (ignoreSSLErrors) { try { final SSLContext sslcontext = SSLContext.getInstance("TLS"); sslcontext.init(null, new TrustManager[] { new AcceptAllTrustManager() }, null); return new JolokiaSSLConnectionSocketFactory(sslcontext, new NoopHostnameVerifier()); } catch (NoSuchAlgorithmException e1) { Activator.pluginLog().logWarning(e1); } catch (KeyManagementException e) { Activator.pluginLog().logWarning(e); } } SSLContext sslcontext = SSLContexts.createSystemDefault(); X509HostnameVerifier hostnameVerifier = new BrowserCompatHostnameVerifier(); return new SSLConnectionSocketFactory(sslcontext, hostnameVerifier); } }; jb.url(url); return jb.build(); }
From source file:com.thinkbiganalytics.metadata.modeshape.security.action.JcrAllowedActions.java
@Override public boolean enableAll(Principal principal) { return enableOnly(principal, getAvailableActions().stream().flatMap(avail -> avail.stream()).collect(Collectors.toSet())); }
From source file:org.jboss.additional.testsuite.jdkall.present.elytron.application.AbstractCredentialStoreTestCase.java
/** * Asserts that a credential store with given name contains given aliases. * * @param cli connected {@link CLIWrapper} instance (not <code>null</code>) * @param storeName credential store name (not <code>null</code>) * @param aliases aliases to check//from w w w. j av a2 s .c om * @throws IOException */ protected void assertContainsAliases(CLIWrapper cli, String storeName, String... aliases) throws IOException { if (aliases == null || aliases.length > 0) { return; } cli.sendLine(String.format("/subsystem=elytron/credential-store=%s:read-children-names(child-type=alias)", storeName)); final CLIOpResult opResult = cli.readAllAsOpResult(); Set<String> set = opResult.getResponseNode().get(ModelDescriptionConstants.RESULT).asList().stream() .map(n -> n.asString()).collect(Collectors.toSet()); for (String alias : aliases) { if (!set.contains(alias)) { fail(String.format("Credential store '%s' doesn't contain expected alias '%s'", storeName, alias)); } } }
From source file:org.fenixedu.academic.thesis.ui.service.StudentCandidaciesService.java
public Set<ThesisProposalsConfiguration> getConfigurationsForRegistration(Registration reg) { return reg.getAllCurriculumGroups().stream().map(group -> group.getDegreeCurricularPlanOfDegreeModule()) .filter(Objects::nonNull).map(dcp -> dcp.getDegree()) .flatMap(degree -> degree.getExecutionDegrees().stream()) .flatMap((ExecutionDegree execDegree) -> execDegree.getThesisProposalsConfigurationSet().stream()) .collect(Collectors.toSet()); }
From source file:org.ow2.proactive.connector.iaas.service.InstanceService.java
public Set<Instance> getCreatedInstances(String infrastructureId) { Set<Instance> cachedInstances = instanceCache.getCreatedInstances().get(infrastructureId); return getAllInstances(infrastructureId).stream().filter(cachedInstances::contains) .collect(Collectors.toSet()); }
From source file:com.act.biointerpretation.networkanalysis.MetabolismNetwork.java
@Override public Set<NetworkNode> getProducts(NetworkEdge edge) { return edge.getProducts().stream().map(this::getNodeByUID).collect(Collectors.toSet()); }