Java Code Examples for com.google.common.collect.ImmutableListMultimap#size()
The following examples show how to use
com.google.common.collect.ImmutableListMultimap#size() .
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: LookupValuesList.java From metasfresh-webui-api-legacy with GNU General Public License v3.0 | 5 votes |
/** * Creates and returns a new {@link LookupValuesList} which contains the lookup values from this list but without the lookup values from <code>valuesToRemove</code>. * The values will be matched by ID only. The display name will be ignored. */ public LookupValuesList removeAll(final LookupValuesList valuesToRemove) { // If nothing to remove, we can return this if (valuesToRemove.isEmpty()) { return this; } // If this list is empty, we can return it if (valuesById.isEmpty()) { return this; } // Create a new values map which does not contain the the values to be removed final ImmutableListMultimap<Object, LookupValue> valuesByIdNew = valuesById.entries().stream() .filter(entry -> !valuesToRemove.containsId(entry.getKey())) .collect(GuavaCollectors.toImmutableListMultimap()); // If nothing was filtered out, we can return this if (valuesById.size() == valuesByIdNew.size()) { return this; } // return new LookupValuesList(valuesByIdNew, ordered, debugProperties); }
Example 2
Source File: TerminalInterface.java From size-analyzer with Apache License 2.0 | 4 votes |
public void displaySuggestions() { ImmutableListMultimap<Category, Suggestion> categorizedSuggestions = categorizeSuggestions(); if (categorizedSuggestions.size() == 0) { System.out.println("No size saving suggestions found."); return; } ImmutableList<Category> categoryDisplayOrder = getCategoryDisplayOrder(categorizedSuggestions); Long runningTotal = 0L; for (Category category : categoryDisplayOrder) { ImmutableList<Suggestion> suggestions = categorizedSuggestions.get(category); Long totalSavings = getBytesSavedForSuggestionList(suggestions); System.out.println( Ansi.ansi() .fg(Color.GREEN) .a(CATEGORY_TO_STRING.get(category)) .fg(Color.RED) .a(humanReadableByteCount(totalSavings)) .reset()); if (showFixes) { applyFixesInteractively(suggestions, category); } else { if (displayDetails) { suggestions.forEach(TerminalInterface::prettyPrintSuggestion); } if (applyFixes) { System.out.println("applying all available fixes for category: " + category); suggestions.stream() .filter(suggestion -> suggestion.getAutoFix() != null) .map(Suggestion::getAutoFix) .forEach(AutoFix::apply); } } runningTotal += totalSavings; } // Print out total size savings suggested. System.out.println( Ansi.ansi() .fg(Color.GREEN) .a("Total size savings of ") .fg(Color.RED) .a(humanReadableByteCount(runningTotal)) .reset() .a(" found.") .reset()); // if we are only showing suggestions, let them know of other available options. if (!applyFixes && !showFixes) { if (!displayDetails) { System.out.println( "The -d flag will display a list of individual suggestions for each category."); } // if there are any suggestions with a fix, explicitly let developers know they can apply them // or be shown them. if (this.suggestions.stream().anyMatch(suggestion -> suggestion.getAutoFix() != null)) { System.out.println( "The --apply-all flag will automatically apply any available fixes while" + " the --show-fixes flag allows for fixes to be selectively applied."); } } }
Example 3
Source File: Publisher.java From buck with Apache License 2.0 | 4 votes |
public ImmutableSet<DeployResult> publish( SourcePathResolverAdapter pathResolver, ImmutableSet<MavenPublishable> publishables) throws DeploymentException { ImmutableListMultimap<UnflavoredBuildTarget, UnflavoredBuildTarget> duplicateBuiltinBuileRules = checkForDuplicatePackagedDeps(publishables); if (duplicateBuiltinBuileRules.size() > 0) { StringBuilder sb = new StringBuilder(); sb.append("Duplicate transitive dependencies for publishable libraries found! This means"); sb.append(StandardSystemProperty.LINE_SEPARATOR); sb.append("that the following libraries would have multiple copies if these libraries were"); sb.append(StandardSystemProperty.LINE_SEPARATOR); sb.append("used together. The can be resolved by adding a maven URL to each target listed"); sb.append(StandardSystemProperty.LINE_SEPARATOR); sb.append("below:"); for (UnflavoredBuildTarget unflavoredBuildTargetView : duplicateBuiltinBuileRules.keySet()) { sb.append(StandardSystemProperty.LINE_SEPARATOR); sb.append(unflavoredBuildTargetView.getFullyQualifiedName()); sb.append(" (referenced by these build targets: "); Joiner.on(", ").appendTo(sb, duplicateBuiltinBuileRules.get(unflavoredBuildTargetView)); sb.append(")"); } throw new DeploymentException(sb.toString()); } ImmutableSet.Builder<DeployResult> deployResultBuilder = ImmutableSet.builder(); for (MavenPublishable publishable : publishables) { DefaultArtifact coords = new DefaultArtifact( Preconditions.checkNotNull( publishable.getMavenCoords().get(), "No maven coordinates specified for published rule ", publishable)); Path relativePathToOutput = pathResolver.getRelativePath( Preconditions.checkNotNull( publishable.getSourcePathToOutput(), "No path to output present in ", publishable)); File mainItem = publishable.getProjectFilesystem().resolve(relativePathToOutput).toFile(); if (!coords.getClassifier().isEmpty()) { deployResultBuilder.add(publish(coords, ImmutableList.of(mainItem))); } try { // If this is the "main" artifact (denoted by lack of classifier) generate and publish // pom alongside File pom = Pom.generatePomFile(pathResolver, publishable).toFile(); deployResultBuilder.add(publish(coords, ImmutableList.of(mainItem, pom))); } catch (IOException e) { throw new RuntimeException(e); } } return deployResultBuilder.build(); }