Example usage for com.google.common.collect ImmutableMultimap.Builder put

List of usage examples for com.google.common.collect ImmutableMultimap.Builder put

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableMultimap.Builder put.

Prototype

@Deprecated
@Override
public boolean put(K key, V value) 

Source Link

Document

Guaranteed to throw an exception and leave the multimap unmodified.

Usage

From source file:de.se_rwth.langeditor.modelstates.ModelStateAssembler.java

private ModelState createNewModelState(IStorage storage, IProject project, String content, Language language) {

    ImmutableMultimap.Builder<SourcePosition, String> syntaxErrorBuilder = ImmutableMultimap.builder();

    ParserRuleContext rootContext = language.getParserConfig().parse(content,
            (pos, message) -> syntaxErrorBuilder.put(pos, message));

    nodes.addNodes(rootContext);//from  ww w. j  a  v  a2  s .co m

    return new ModelStateBuilder().setStorage(storage).setProject(project).setContent(content)
            .setLanguage(language).setRootNode(Nodes.getAstNode(rootContext).get()).setRootContext(rootContext)
            .setSyntaxErrors(syntaxErrorBuilder.build())
            .setLastModelState(observableModelStates.findModelState(storage).orElse(null)).build();
}

From source file:com.google.idea.blaze.base.rulemaps.SourceToRuleMapImpl.java

@Nullable
private ImmutableMultimap<File, Label> initSourceToTargetMap() {
    BlazeProjectData blazeProjectData = BlazeProjectDataManager.getInstance(project).getBlazeProjectData();
    if (blazeProjectData == null) {
        return null;
    }//  w  ww . j a va 2 s  .co m
    ImmutableMultimap.Builder<File, Label> sourceToTargetMap = ImmutableMultimap.builder();
    for (RuleIdeInfo rule : blazeProjectData.ruleMap.values()) {
        Label label = rule.label;
        for (ArtifactLocation sourceArtifact : rule.sources) {
            sourceToTargetMap.put(sourceArtifact.getFile(), label);
        }
    }
    return sourceToTargetMap.build();
}

From source file:com.outerspacecat.icalendar.VTimeZone.java

/**
 * Creates a new time zone./*  w  w  w . ja  v  a2  s  .com*/
 * 
 * @param id the time zone id. Must be non {@code null}.
 * @param observances the time zone observances. Must be non {@code null}, all
 *        elements must be non {@code null}. Must contain at least one
 *        element.
 * @param extraProperties the extra properties of the time zone. Must be non
 *        {@code null}, all elements must be non {@code null}, may be empty.
 * @param extraComponents the extra components of the time zone. Must be non
 *        {@code null}, all elements must be non {@code null}, may be empty.
 */
public VTimeZone(final TypedProperty<TextType> id, final Iterable<VTimeZoneObservance> observances,
        final Iterable<Property> extraProperties, final Iterable<Component> extraComponents) {
    Preconditions.checkNotNull(id, "id required");
    Preconditions.checkNotNull(observances, "observances required");
    Preconditions.checkArgument(observances.iterator().hasNext(), "one or more observances required");
    for (VTimeZoneObservance observance : observances)
        Preconditions.checkNotNull(observance, "each observance must be non null");
    Preconditions.checkNotNull(extraProperties, "extraProperties required");
    for (Property prop : extraProperties)
        Preconditions.checkNotNull(prop, "each extra property must be non null");
    Preconditions.checkNotNull(extraComponents, "extraComponents required");
    for (Component comp : extraComponents)
        Preconditions.checkNotNull(comp, "each extra component must be non null");

    this.id = id;

    this.observances = ImmutableSet.copyOf(observances);

    ImmutableMultimap.Builder<String, Property> extraPropertiesBuilder = ImmutableMultimap.builder();
    for (Property prop : extraProperties)
        extraPropertiesBuilder.put(prop.getName().getName(), prop);
    this.extraProperties = extraPropertiesBuilder.build();

    ImmutableMultimap.Builder<String, Component> extraComponentsBuilder = ImmutableMultimap.builder();
    for (Component comp : extraComponents)
        extraComponentsBuilder.put(comp.getName(), comp);
    this.extraComponents = extraComponentsBuilder.build();
}

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
                    .put(AppleTestBundleParamsKey.fromAppleTestDescriptionArg(test.getConstructorArg()), test);
        } else {//from  w w  w  .ja  v a2 s  .  c om
            ungroupedTestsBuilder.put(schemeName, test);
        }
    }
}

From source file:com.facebook.presto.sql.planner.assertions.ExpressionAliases.java

public void updateAssignments(Map<Symbol, Expression> assignments) {
    ImmutableMultimap.Builder<String, Expression> mapUpdate = ImmutableMultimap.builder();
    for (Map.Entry<Symbol, Expression> assignment : assignments.entrySet()) {
        for (String alias : map.keys()) {
            if (map.get(alias).contains(assignment.getKey().toSymbolReference())) {
                mapUpdate.put(alias, assignment.getValue());
            }/*from  w w w .  j  a  v  a2  s .  c o m*/
        }
    }
    map.putAll(mapUpdate.build());
}

From source file:org.gradle.internal.execution.history.impl.FileCollectionFingerprintSerializer.java

private ImmutableMultimap<String, HashCode> readRootHashes(Decoder decoder) throws IOException {
    int numberOfRoots = decoder.readSmallInt();
    if (numberOfRoots == 0) {
        return ImmutableMultimap.of();
    }//from   w w  w. ja  va  2  s. c om
    ImmutableMultimap.Builder<String, HashCode> builder = ImmutableMultimap.builder();
    for (int i = 0; i < numberOfRoots; i++) {
        String absolutePath = stringInterner.intern(decoder.readString());
        HashCode rootHash = hashCodeSerializer.read(decoder);
        builder.put(absolutePath, rootHash);
    }
    return builder.build();
}

From source file:com.qualys.feign.jaxrs.BeanParamTransformerFactory.java

Multimap<String, Annotation> getNames(Annotation[] annotations) {
    ImmutableMultimap.Builder<String, Annotation> names = ImmutableMultimap.builder();
    for (Annotation annotation : annotations) {
        Class<?> cls = annotation.getClass();
        if (QueryParam.class.isAssignableFrom(cls))
            names.put(((QueryParam) annotation).value(), annotation);

        if (FormParam.class.isAssignableFrom(cls))
            names.put(((FormParam) annotation).value(), annotation);

        if (HeaderParam.class.isAssignableFrom(cls))
            names.put(((HeaderParam) annotation).value(), annotation);

        if (PathParam.class.isAssignableFrom(cls))
            names.put(((PathParam) annotation).value(), annotation);
    }//from ww  w  .  jav a  2  s  .  com

    return names.build();
}

From source file:com.isotrol.impe3.pms.core.support.SatisfiabilitySupport.java

/**
 * Constructor./*from w  w w . ja v a2 s.c  o  m*/
 * @param dfns Connector definitions.
 */
public SatisfiabilitySupport(Iterable<ModuleDefinition<?>> modules) {
    final SatisfiabilityGraph graph = new SatisfiabilityGraph(modules);
    final ImmutableMultimap.Builder<ModuleDefinition<?>, String> builder = ImmutableMultimap.builder();
    for (DependencyNode dn : graph.getDependencies()) {
        if (!graph.isSatisfiable(dn)) {
            builder.put(dn.module.module, dn.name);
        }
    }
    unsatisfiable = builder.build();
}

From source file:com.facebook.presto.execution.MockRemoteTaskFactory.java

public RemoteTask createTableScanTask(Node newNode, List<Split> splits,
        SplitCountChangeListener splitCountChangeListener) {
    TaskId taskId = new TaskId(new StageId("test", "1"), "1");
    Symbol symbol = new Symbol("column");
    PlanNodeId tableScanNodeId = new PlanNodeId("test");
    PlanNodeId sourceId = new PlanNodeId("sourceId");
    PlanFragment testFragment = new PlanFragment(new PlanFragmentId("test"),
            new TableScanNode(new PlanNodeId("test"), new TableHandle("test", new TestingTableHandle()),
                    ImmutableList.of(symbol), ImmutableMap.of(symbol, new TestingColumnHandle("column")),
                    Optional.empty(), TupleDomain.all(), null),
            ImmutableMap.<Symbol, Type>of(symbol, VARCHAR), ImmutableList.of(symbol),
            PlanFragment.PlanDistribution.SOURCE, tableScanNodeId, PlanFragment.OutputPartitioning.NONE,
            Optional.empty(), Optional.empty(), Optional.empty());

    ImmutableMultimap.Builder<PlanNodeId, Split> initialSplits = ImmutableMultimap.builder();
    for (Split sourceSplit : splits) {
        initialSplits.put(sourceId, sourceSplit);
    }/*from   www. java  2  s.c o m*/
    return createRemoteTask(TEST_SESSION, taskId, newNode, testFragment, initialSplits.build(),
            OutputBuffers.INITIAL_EMPTY_OUTPUT_BUFFERS, splitCountChangeListener);
}

From source file:com.google.idea.blaze.base.targetmaps.SourceToTargetMapImpl.java

@Nullable
private ImmutableMultimap<File, TargetKey> initSourceToTargetMap() {
    BlazeProjectData blazeProjectData = BlazeProjectDataManager.getInstance(project).getBlazeProjectData();
    if (blazeProjectData == null) {
        return null;
    }/*from   w ww .j  a  va2s.  co  m*/
    ArtifactLocationDecoder artifactLocationDecoder = blazeProjectData.artifactLocationDecoder;
    ImmutableMultimap.Builder<File, TargetKey> sourceToTargetMap = ImmutableMultimap.builder();
    for (TargetIdeInfo target : blazeProjectData.targetMap.targets()) {
        TargetKey key = target.key;
        for (ArtifactLocation sourceArtifact : target.sources) {
            sourceToTargetMap.put(artifactLocationDecoder.decode(sourceArtifact), key);
        }
    }
    return sourceToTargetMap.build();
}