Java Code Examples for com.google.common.collect.ImmutableSetMultimap#keySet()
The following examples show how to use
com.google.common.collect.ImmutableSetMultimap#keySet() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Resolver.java From buck with Apache License 2.0 | 6 votes |
private void createBuckFiles(ImmutableSetMultimap<Path, Prebuilt> buckFilesData) throws IOException { URL templateUrl = Resources.getResource(TEMPLATE); String template = Resources.toString(templateUrl, UTF_8); STGroupString groups = new STGroupString("prebuilt-template", template); for (Path key : buckFilesData.keySet()) { Path buckFile = key.resolve("BUCK"); if (Files.exists(buckFile)) { Files.delete(buckFile); } ST st = Objects.requireNonNull(groups.getInstanceOf("/prebuilts")); st.add("data", buckFilesData.get(key)); Files.write(buckFile, st.render().getBytes(UTF_8)); } }
Example 2
Source File: ViewGeoLocationsRestController.java From metasfresh-webui-api-legacy with GNU General Public License v3.0 | 5 votes |
private List<JsonViewRowGeoLocation> retrieveGeoLocationsForBPartnerLocationId(final ImmutableSetMultimap<Integer, DocumentId> rowIdsByBPartnerLocationRepoId) { if (rowIdsByBPartnerLocationRepoId.isEmpty()) { return ImmutableList.of(); } final List<JsonViewRowGeoLocation> result = new ArrayList<>(); final ImmutableSet<Integer> bpartnerLocationRepoIds = rowIdsByBPartnerLocationRepoId.keySet(); for (final GeographicalCoordinatesWithBPartnerLocationId bplCoordinates : bpartnersRepo.getGeoCoordinatesByBPartnerLocationIds(bpartnerLocationRepoIds)) { final int bpartnerLocationRepoId = bplCoordinates.getBpartnerLocationId().getRepoId(); final ImmutableSet<DocumentId> rowIds = rowIdsByBPartnerLocationRepoId.get(bpartnerLocationRepoId); if (rowIds.isEmpty()) { // shall not happen logger.warn("Ignored unexpected bpartnerLocationId={}. We have no rows for it.", bpartnerLocationRepoId); continue; } final GeographicalCoordinates coordinate = bplCoordinates.getCoordinate(); for (final DocumentId rowId : rowIds) { result.add(JsonViewRowGeoLocation.builder() .rowId(rowId) .latitude(coordinate.getLatitude()) .longitude(coordinate.getLongitude()) .build()); } } return result; }
Example 3
Source File: ViewGeoLocationsRestController.java From metasfresh-webui-api-legacy with GNU General Public License v3.0 | 5 votes |
private List<JsonViewRowGeoLocation> retrieveGeoLocationsForBPartnerId(final ImmutableSetMultimap<BPartnerId, DocumentId> rowIdsByBPartnerId) { if (rowIdsByBPartnerId.isEmpty()) { return ImmutableList.of(); } final List<JsonViewRowGeoLocation> result = new ArrayList<>(); final ImmutableSet<BPartnerId> bpartnerIds = rowIdsByBPartnerId.keySet(); for (final GeographicalCoordinatesWithBPartnerLocationId bplCoordinates : bpartnersRepo.getGeoCoordinatesByBPartnerIds(bpartnerIds)) { final BPartnerId bpartnerId = bplCoordinates.getBPartnerId(); final ImmutableSet<DocumentId> rowIds = rowIdsByBPartnerId.get(bpartnerId); if (rowIds.isEmpty()) { // shall not happen logger.warn("Ignored unexpected bpartnerId={}. We have no rows for it.", bpartnerId); continue; } final GeographicalCoordinates coordinate = bplCoordinates.getCoordinate(); for (final DocumentId rowId : rowIds) { result.add(JsonViewRowGeoLocation.builder() .rowId(rowId) .latitude(coordinate.getLatitude()) .longitude(coordinate.getLongitude()) .build()); } } return result; }
Example 4
Source File: WorkspaceAndProjectGenerator.java From buck with Apache License 2.0 | 5 votes |
private void buildWorkspaceSchemeTests( Optional<BuildTarget> mainTarget, TargetGraph projectGraph, boolean includeProjectTests, boolean includeDependenciesTests, ImmutableSetMultimap<String, Optional<TargetNode<?>>> schemeNameToSrcTargetNode, ImmutableSetMultimap<String, TargetNode<AppleTestDescriptionArg>> extraTestNodes, ImmutableSetMultimap.Builder<String, TargetNode<AppleTestDescriptionArg>> selectedTestsBuilder, ImmutableSetMultimap.Builder<String, TargetNode<?>> buildForTestNodesBuilder) { for (String schemeName : schemeNameToSrcTargetNode.keySet()) { ImmutableSet<TargetNode<?>> targetNodes = schemeNameToSrcTargetNode.get(schemeName).stream() .flatMap(RichStream::from) .collect(ImmutableSet.toImmutableSet()); ImmutableSet<TargetNode<AppleTestDescriptionArg>> testNodes = getOrderedTestNodes( mainTarget, projectGraph, includeProjectTests, includeDependenciesTests, targetNodes, extraTestNodes.get(schemeName)); selectedTestsBuilder.putAll(schemeName, testNodes); buildForTestNodesBuilder.putAll( schemeName, Iterables.filter( TopologicalSort.sort(projectGraph), getTransitiveDepsAndInputs( xcodeDescriptions, projectGraph, dependenciesCache, testNodes, targetNodes) ::contains)); } }
Example 5
Source File: WorkspaceAndProjectGenerator.java From buck with Apache License 2.0 | 5 votes |
private void buildWorkspaceSchemeTests( Optional<BuildTarget> mainTarget, TargetGraph projectGraph, boolean includeProjectTests, boolean includeDependenciesTests, ImmutableSetMultimap<String, Optional<TargetNode<?>>> schemeNameToSrcTargetNode, ImmutableSetMultimap<String, TargetNode<AppleTestDescriptionArg>> extraTestNodes, ImmutableSetMultimap.Builder<String, TargetNode<AppleTestDescriptionArg>> selectedTestsBuilder, ImmutableSetMultimap.Builder<String, TargetNode<?>> buildForTestNodesBuilder) { for (String schemeName : schemeNameToSrcTargetNode.keySet()) { ImmutableSet<TargetNode<?>> targetNodes = schemeNameToSrcTargetNode.get(schemeName).stream() .flatMap(RichStream::from) .collect(ImmutableSet.toImmutableSet()); ImmutableSet<TargetNode<AppleTestDescriptionArg>> testNodes = getOrderedTestNodes( mainTarget, projectGraph, includeProjectTests, includeDependenciesTests, targetNodes, extraTestNodes.get(schemeName)); selectedTestsBuilder.putAll(schemeName, testNodes); buildForTestNodesBuilder.putAll( schemeName, Iterables.filter( TopologicalSort.sort(projectGraph), getTransitiveDepsAndInputs( xcodeDescriptions, projectGraph, dependenciesCache, testNodes, targetNodes) ::contains)); } }
Example 6
Source File: LinkageMonitor.java From cloud-opensource-java with Apache License 2.0 | 4 votes |
/** * Returns new problems in the BOM specified by {@code groupId} and {@code artifactId}. This * method compares the latest release of the BOM and its snapshot version which uses artifacts in * {@link #localArtifacts}. */ private ImmutableSet<SymbolProblem> run(String groupId, String artifactId) throws RepositoryException, IOException, MavenRepositoryException, ModelBuildingException { String latestBomCoordinates = RepositoryUtility.findLatestCoordinates(repositorySystem, groupId, artifactId); logger.info("BOM Coordinates: " + latestBomCoordinates); Bom baseline = Bom.readBom(latestBomCoordinates); ImmutableSet<SymbolProblem> problemsInBaseline = LinkageChecker.create(baseline, null).findSymbolProblems().keySet(); Bom snapshot = copyWithSnapshot(repositorySystem, session, baseline, localArtifacts); // Comparing coordinates because DefaultArtifact does not override equals ImmutableList<String> baselineCoordinates = coordinatesList(baseline.getManagedDependencies()); ImmutableList<String> snapshotCoordinates = coordinatesList(snapshot.getManagedDependencies()); if (baselineCoordinates.equals(snapshotCoordinates)) { logger.info( "Snapshot is same as baseline. Not running comparison."); logger.info( "Baseline coordinates: " + Joiner.on(";").join(baselineCoordinates)); return ImmutableSet.of(); } ImmutableList<Artifact> snapshotManagedDependencies = snapshot.getManagedDependencies(); ClassPathResult classPathResult = (new ClassPathBuilder()).resolve(snapshotManagedDependencies); ImmutableList<ClassPathEntry> classpath = classPathResult.getClassPath(); List<ClassPathEntry> entryPointJars = classpath.subList(0, snapshotManagedDependencies.size()); ImmutableSetMultimap<SymbolProblem, ClassFile> snapshotSymbolProblems = LinkageChecker.create(classpath, ImmutableSet.copyOf(entryPointJars), null) .findSymbolProblems(); ImmutableSet<SymbolProblem> problemsInSnapshot = snapshotSymbolProblems.keySet(); if (problemsInBaseline.equals(problemsInSnapshot)) { logger.info( "Snapshot versions have the same " + problemsInBaseline.size() + " errors as baseline"); return ImmutableSet.of(); } Set<SymbolProblem> fixedProblems = Sets.difference(problemsInBaseline, problemsInSnapshot); if (!fixedProblems.isEmpty()) { logger.info(messageForFixedErrors(fixedProblems)); } Set<SymbolProblem> newProblems = Sets.difference(problemsInSnapshot, problemsInBaseline); if (!newProblems.isEmpty()) { logger.severe( messageForNewErrors(snapshotSymbolProblems, problemsInBaseline, classPathResult)); } return ImmutableSet.copyOf(newProblems); }
Example 7
Source File: TreasuryShareRound.java From Rails with GNU General Public License v2.0 | 4 votes |
/** * Create a list of certificates that a player may buy in a Stock Round, * taking all rules into account. * * @return List of buyable certificates. */ @Override public void setBuyableCerts() { ImmutableSet<PublicCertificate> certs; PublicCertificate cert; PortfolioModel from; int price; int number; int cash = operatingCompany.getCash(); /* Get the unique Pool certificates and check which ones can be bought */ from = pool; ImmutableSetMultimap<PublicCompany, PublicCertificate> map = from.getCertsPerCompanyMap(); for (PublicCompany comp : map.keySet()) { certs = map.get(comp); // if (certs.isEmpty()) continue; // TODO: Check if removal is correct cert = Iterables.get(certs, 0); // TODO For now, only consider own certificates. // This will have to be revisited with 1841. if (comp != operatingCompany) continue; // Shares already owned int ownedShare = operatingCompany.getPortfolioModel().getShare(operatingCompany); // Max share that may be owned int maxShare = GameDef.getGameParameterAsInt(this, GameDef.Parm.TREASURY_SHARE_LIMIT); // Max number of shares to add int maxBuyable = (maxShare - ownedShare) / operatingCompany.getShareUnit(); // Max number of shares to buy number = Math.min(certs.size(), maxBuyable); if (number == 0) continue; price = comp.getMarketPrice(); // Does the company have enough cash? while (number > 0 && cash < number * price) number--; if (number > 0) { possibleActions.add(new BuyCertificate(comp, cert.getShare(), from.getParent(), price, number)); } } }