Example usage for com.google.common.collect ImmutableSetMultimap builder

List of usage examples for com.google.common.collect ImmutableSetMultimap builder

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableSetMultimap builder.

Prototype

public static <K, V> Builder<K, V> builder() 

Source Link

Document

Returns a new Builder .

Usage

From source file:com.facebook.buck.features.apple.project.ProjectGenerator.java

/**
 * Convert a list of rules that should be somehow included into the bundle, into build phases
 * which copies them into the bundle. The parameters of these copy phases are divined by
 * scrutinizing the type of node we want to include.
 *//*w  w w.  jav a 2  s.c o  m*/
private ImmutableList<PBXBuildPhase> getCopyFilesBuildPhases(Iterable<TargetNode<?>> copiedNodes) {

    // Bucket build rules into bins by their destinations
    ImmutableSetMultimap.Builder<CopyFilePhaseDestinationSpec, TargetNode<?>> ruleByDestinationSpecBuilder = ImmutableSetMultimap
            .builder();
    for (TargetNode<?> copiedNode : copiedNodes) {
        getDestinationSpec(copiedNode).ifPresent(copyFilePhaseDestinationSpec -> ruleByDestinationSpecBuilder
                .put(copyFilePhaseDestinationSpec, 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();
}