List of usage examples for com.google.common.collect ImmutableSetMultimap builder
public static <K, V> Builder<K, V> builder()
From source file:com.facebook.buck.apple.WorkspaceAndProjectGenerator.java
private static void buildWorkspaceSchemeTests(Optional<BuildTarget> mainTarget, TargetGraph projectGraph, boolean includeProjectTests, boolean includeDependenciesTests, ImmutableSetMultimap<String, Optional<TargetNode<?>>> schemeNameToSrcTargetNode, ImmutableSetMultimap<String, TargetNode<AppleTestDescription.Arg>> extraTestNodes, ImmutableSetMultimap.Builder<String, TargetNode<AppleTestDescription.Arg>> selectedTestsBuilder, ImmutableSetMultimap.Builder<String, TargetNode<?>> buildForTestNodesBuilder) { for (String schemeName : schemeNameToSrcTargetNode.keySet()) { ImmutableSet<TargetNode<?>> targetNodes = ImmutableSet .copyOf(Optional.presentInstances(schemeNameToSrcTargetNode.get(schemeName))); ImmutableSet<TargetNode<AppleTestDescription.Arg>> testNodes = getOrderedTestNodes(mainTarget, projectGraph, includeProjectTests, includeDependenciesTests, targetNodes, extraTestNodes.get(schemeName)); selectedTestsBuilder.putAll(schemeName, testNodes); buildForTestNodesBuilder.putAll(schemeName, TopologicalSort.sort(projectGraph, Predicates.in(getTransitiveDepsAndInputs(projectGraph, testNodes, targetNodes)))); }//w w w .j av a 2 s . c o m }
From source file:com.facebook.buck.apple.WorkspaceAndProjectGenerator.java
@VisibleForTesting static void groupSchemeTests(ImmutableSet<TargetNode<AppleTestDescription.Arg>> groupableTests, ImmutableSetMultimap<String, TargetNode<AppleTestDescription.Arg>> selectedTests, ImmutableMultimap.Builder<AppleTestBundleParamsKey, TargetNode<AppleTestDescription.Arg>> groupedTestsBuilder, ImmutableSetMultimap.Builder<String, TargetNode<AppleTestDescription.Arg>> ungroupedTestsBuilder) { for (Map.Entry<String, TargetNode<AppleTestDescription.Arg>> testEntry : selectedTests.entries()) { String schemeName = testEntry.getKey(); TargetNode<AppleTestDescription.Arg> test = testEntry.getValue(); if (groupableTests.contains(test)) { Preconditions.checkState(test.getConstructorArg().canGroup(), "Groupable test should actually be groupable."); groupedTestsBuilder//from www . j av a 2 s . c o m .put(AppleTestBundleParamsKey.fromAppleTestDescriptionArg(test.getConstructorArg()), test); } else { ungroupedTestsBuilder.put(schemeName, test); } } }
From source file:com.facebook.buck.apple.project_generator.WorkspaceAndProjectGenerator.java
private void buildWorkspaceSchemeTests(Optional<BuildTarget> mainTarget, TargetGraph projectGraph, boolean includeProjectTests, boolean includeDependenciesTests, ImmutableSetMultimap<String, Optional<TargetNode<?, ?>>> schemeNameToSrcTargetNode, ImmutableSetMultimap<String, TargetNode<AppleTestDescription.Arg, ?>> extraTestNodes, ImmutableSetMultimap.Builder<String, TargetNode<AppleTestDescription.Arg, ?>> selectedTestsBuilder, ImmutableSetMultimap.Builder<String, TargetNode<?, ?>> buildForTestNodesBuilder) { for (String schemeName : schemeNameToSrcTargetNode.keySet()) { ImmutableSet<TargetNode<?, ?>> targetNodes = schemeNameToSrcTargetNode.get(schemeName).stream() .flatMap(Optionals::toStream).collect(MoreCollectors.toImmutableSet()); ImmutableSet<TargetNode<AppleTestDescription.Arg, ?>> testNodes = getOrderedTestNodes(mainTarget, projectGraph, includeProjectTests, includeDependenciesTests, targetNodes, extraTestNodes.get(schemeName)); selectedTestsBuilder.putAll(schemeName, testNodes); buildForTestNodesBuilder.putAll(schemeName, Iterables.filter(TopologicalSort.sort(projectGraph), getTransitiveDepsAndInputs(projectGraph, dependenciesCache, testNodes, targetNodes)::contains)); }//from ww w .j a va2 s.c om }
From source file:com.facebook.buck.features.apple.project.WorkspaceAndProjectGenerator.java
private static void addExtraWorkspaceSchemes(XCodeDescriptions xcodeDescriptions, TargetGraph projectGraph, AppleDependenciesCache dependenciesCache, ImmutableSortedMap<String, BuildTarget> extraSchemes, ImmutableMap.Builder<String, XcodeWorkspaceConfigDescriptionArg> schemeConfigsBuilder, ImmutableSetMultimap.Builder<String, Optional<TargetNode<?>>> schemeNameToSrcTargetNodeBuilder, ImmutableSetMultimap.Builder<String, TargetNode<AppleTestDescriptionArg>> extraTestNodesBuilder) { for (Map.Entry<String, BuildTarget> extraSchemeEntry : extraSchemes.entrySet()) { BuildTarget extraSchemeTarget = extraSchemeEntry.getValue(); Optional<TargetNode<?>> extraSchemeNode = projectGraph.getOptional(extraSchemeTarget); if (!extraSchemeNode.isPresent() || !(extraSchemeNode.get().getDescription() instanceof XcodeWorkspaceConfigDescription)) { throw new HumanReadableException( "Extra scheme target '%s' should be of type 'xcode_workspace_config'", extraSchemeTarget); }//from ww w. j a v a2 s.c om XcodeWorkspaceConfigDescriptionArg extraSchemeArg = (XcodeWorkspaceConfigDescriptionArg) extraSchemeNode .get().getConstructorArg(); String schemeName = extraSchemeEntry.getKey(); addWorkspaceScheme(xcodeDescriptions, projectGraph, dependenciesCache, schemeName, extraSchemeArg, schemeConfigsBuilder, schemeNameToSrcTargetNodeBuilder, extraTestNodesBuilder); } }
From source file:com.google.auto.value.processor.AutoValueProcessor.java
private ImmutableSetMultimap<ExecutableElement, String> allMethodExcludedAnnotations( Iterable<ExecutableElement> methods) { ImmutableSetMultimap.Builder<ExecutableElement, String> result = ImmutableSetMultimap.builder(); for (ExecutableElement method : methods) { result.putAll(method, getFieldOfClasses(method, AutoValue.CopyAnnotations.class, "exclude", processingEnv.getElementUtils())); }/*from w ww . j a va 2 s .c o m*/ return result.build(); }
From source file:com.google.template.soy.SoyFileSet.java
private ImmutableSetMultimap<String, String> getTransitiveIjs(SoyFileSetNode soyTree, TemplateRegistry registry) {/*from www . java 2s .c o m*/ ImmutableMap<TemplateNode, IjParamsInfo> templateToIjParamsInfoMap = new FindIjParamsVisitor(registry, errorReporter).execOnAllTemplates(soyTree); ImmutableSetMultimap.Builder<String, String> templateToTranstivieIjParams = ImmutableSetMultimap.builder(); for (Map.Entry<TemplateNode, IjParamsInfo> entry : templateToIjParamsInfoMap.entrySet()) { templateToTranstivieIjParams.putAll(entry.getKey().getTemplateName(), entry.getValue().ijParamSet); } return templateToTranstivieIjParams.build(); }
From source file:com.facebook.buck.features.apple.project.WorkspaceAndProjectGenerator.java
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(Optionals::toStream).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)); }/*from w w w . j a v a 2 s . c om*/ }
From source file:dagger.internal.codegen.BindingGraphFactory.java
/** * A multimap of those {@code declarations} that are multibinding contribution declarations, * indexed by the key of the set or map to which they contribute. *//* ww w.j a v a 2s.c o m*/ static <T extends BindingDeclaration> ImmutableSetMultimap<Key, T> multibindingContributionsByMultibindingKey( Iterable<T> declarations) { ImmutableSetMultimap.Builder<Key, T> builder = ImmutableSetMultimap.builder(); for (T declaration : declarations) { if (declaration.key().multibindingContributionIdentifier().isPresent()) { builder.put( declaration.key().toBuilder().multibindingContributionIdentifier(Optional.empty()).build(), declaration); } } return builder.build(); }
From source file:com.facebook.buck.apple.ProjectGenerator.java
private ImmutableList<PBXBuildPhase> getCopyFilesBuildPhases(Iterable<TargetNode<?>> copiedNodes) { // Bucket build rules into bins by their destinations ImmutableSetMultimap.Builder<CopyFilePhaseDestinationSpec, TargetNode<?>> ruleByDestinationSpecBuilder = ImmutableSetMultimap .builder();/*w ww . j a v a 2 s. c o m*/ for (TargetNode<?> copiedNode : copiedNodes) { Optional<CopyFilePhaseDestinationSpec> optionalDestinationSpec = getDestinationSpec(copiedNode); if (optionalDestinationSpec.isPresent()) { ruleByDestinationSpecBuilder.put(optionalDestinationSpec.get(), copiedNode); } } ImmutableList.Builder<PBXBuildPhase> phases = ImmutableList.builder(); ImmutableSetMultimap<CopyFilePhaseDestinationSpec, TargetNode<?>> ruleByDestinationSpec = ruleByDestinationSpecBuilder .build(); // Emit a copy files phase for each destination. for (CopyFilePhaseDestinationSpec destinationSpec : ruleByDestinationSpec.keySet()) { Iterable<TargetNode<?>> targetNodes = ruleByDestinationSpec.get(destinationSpec); phases.add(getSingleCopyFilesBuildPhase(destinationSpec, targetNodes)); } return phases.build(); }
From source file:com.facebook.buck.apple.project_generator.ProjectGenerator.java
private ImmutableList<PBXBuildPhase> getCopyFilesBuildPhases(Iterable<TargetNode<?, ?>> copiedNodes) { // Bucket build rules into bins by their destinations ImmutableSetMultimap.Builder<CopyFilePhaseDestinationSpec, TargetNode<?, ?>> ruleByDestinationSpecBuilder = ImmutableSetMultimap .builder();// w w w. j a v a2s . c o m for (TargetNode<?, ?> copiedNode : copiedNodes) { Optional<CopyFilePhaseDestinationSpec> optionalDestinationSpec = getDestinationSpec(copiedNode); if (optionalDestinationSpec.isPresent()) { ruleByDestinationSpecBuilder.put(optionalDestinationSpec.get(), copiedNode); } } ImmutableList.Builder<PBXBuildPhase> phases = ImmutableList.builder(); ImmutableSetMultimap<CopyFilePhaseDestinationSpec, TargetNode<?, ?>> ruleByDestinationSpec = ruleByDestinationSpecBuilder .build(); // Emit a copy files phase for each destination. for (CopyFilePhaseDestinationSpec destinationSpec : ruleByDestinationSpec.keySet()) { Iterable<TargetNode<?, ?>> targetNodes = ruleByDestinationSpec.get(destinationSpec); phases.add(getSingleCopyFilesBuildPhase(destinationSpec, targetNodes)); } return phases.build(); }