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

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

Introduction

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

Prototype

@Beta
public static <K, V> ImmutableSetMultimap<K, V> copyOf(
        Iterable<? extends Entry<? extends K, ? extends V>> entries) 

Source Link

Document

Returns an immutable multimap containing the specified entries.

Usage

From source file:io.usethesource.criterion.impl.immutable.guava.ImmutableGuavaSetMultimap.java

@Override
public JmhSetMultimap remove(JmhValue key, JmhValue value) {
    final SetMultimap<JmhValue, JmhValue> tmpContent = HashMultimap.create(content);
    tmpContent.remove(key, value);//from ww  w.j  av  a2 s . c  o m

    final ImmutableSetMultimap<JmhValue, JmhValue> newContent = ImmutableSetMultimap.copyOf(tmpContent);

    return new ImmutableGuavaSetMultimap(newContent);
}

From source file:uk.ac.ebi.atlas.solr.query.GeneQueryResponse.java

public ImmutableSetMultimap<String, String> getQueryTermsToIds() {
    return ImmutableSetMultimap.copyOf(geneIdsByQueryTerm);
}

From source file:org.carrot2.output.metrics.IdealPartitioningBasedMetric.java

/**
 * Returns documents grouped by partitions.
 *///from w  w  w  . ja  v a 2s  . c  om
SetMultimap<Object, Document> getDocumentsByPartition(List<Document> documents) {
    final SetMultimap<Object, Document> index = HashMultimap.create();
    for (Document document : documents) {
        final Collection<Object> partitions = document.getField(partitionIdFieldName);
        for (Object partition : partitions) {
            index.put(partition, document);
        }
    }

    return ImmutableSetMultimap.copyOf(index);
}

From source file:org.lanternpowered.server.game.LanternGameDictionary.java

@Override
public SetMultimap<String, Entry> getAll() {
    return ImmutableSetMultimap.copyOf(this.map);
}

From source file:com.facebook.buck.cli.OwnersReport.java

OwnersReport(SetMultimap<TargetNode<?, ?>, Path> owners, Set<Path> inputsWithNoOwners,
        Set<String> nonExistentInputs, Set<String> nonFileInputs) {
    this.owners = ImmutableSetMultimap.copyOf(owners);
    this.inputsWithNoOwners = ImmutableSet.copyOf(inputsWithNoOwners);
    this.nonExistentInputs = ImmutableSet.copyOf(nonExistentInputs);
    this.nonFileInputs = ImmutableSet.copyOf(nonFileInputs);
}

From source file:io.usethesource.criterion.impl.immutable.guava.ImmutableGuavaSetMultimap.java

@Override
public JmhSetMultimap put(JmhValue key, JmhValue value) {
    final SetMultimap<JmhValue, JmhValue> tmpContent = HashMultimap.create(content);
    tmpContent.removeAll(key);/*from w  w w . ja  va 2s  .com*/
    tmpContent.put(key, value);

    final ImmutableSetMultimap<JmhValue, JmhValue> newContent = ImmutableSetMultimap.copyOf(tmpContent);

    return new ImmutableGuavaSetMultimap(newContent);
}

From source file:de.rkl.tools.tzconv.model.ApplicationModel.java

private static SetMultimap<ZoneOffset, ZoneId> sortAvailableZoneIds() {
    final SortedSetMultimap<ZoneOffset, ZoneId> zoneIdMap = TreeMultimap.create(Ordering.natural().reverse(),
            new Ordering<ZoneId>() {
                @Override/*from w  w w .  ja  v a2s  . c  o m*/
                public int compare(final ZoneId zoneId1, final ZoneId zoneId2) {
                    return ComparisonChain.start().compare(zoneId1.toString(), zoneId2.toString()).result();
                }
            }.nullsFirst());
    ZoneId.getAvailableZoneIds().stream().forEach(zoneId -> {
        final ZoneId zoneIdObject = ZoneId.of(zoneId);
        zoneIdMap.put(zoneIdObject.getRules().getStandardOffset(Instant.now()), zoneIdObject);
    });
    return ImmutableSetMultimap.copyOf(zoneIdMap);
}

From source file:org.opendaylight.yangtools.yang.parser.impl.SchemaContextImpl.java

SchemaContextImpl(final Set<Module> modules, final Map<ModuleIdentifier, String> identifiersToSources) {
    this.identifiersToSources = ImmutableMap.copyOf(identifiersToSources);

    /*/*from  w w w.  j a v  a 2  s. c  om*/
    * Instead of doing this on each invocation of getModules(), pre-compute
    * it once and keep it around -- better than the set we got in.
    */
    this.modules = ImmutableSet.copyOf(ModuleDependencySort.sort(modules.toArray(new Module[modules.size()])));

    /*
    * The most common lookup is from Namespace->Module.
    *
    * RESTCONF performs lookups based on module name only, where it wants
    * to receive the latest revision
    *
    * Invest some quality time in building up lookup tables for both.
    */
    final SetMultimap<URI, Module> nsMap = Multimaps.newSetMultimap(new TreeMap<URI, Collection<Module>>(),
            MODULE_SET_SUPPLIER);
    final SetMultimap<String, Module> nameMap = Multimaps
            .newSetMultimap(new TreeMap<String, Collection<Module>>(), MODULE_SET_SUPPLIER);

    for (Module m : modules) {
        nameMap.put(m.getName(), m);
        nsMap.put(m.getNamespace(), m);
    }

    namespaceToModules = ImmutableSetMultimap.copyOf(nsMap);
    nameToModules = ImmutableSetMultimap.copyOf(nameMap);
}

From source file:org.kairosdb.core.datastore.AbstractDataPointGroup.java

public SetMultimap<String, String> getTags() {
    return (ImmutableSetMultimap.copyOf(tags));
}

From source file:org.onos.yangtools.yang.parser.stmt.rfc6020.effective.EffectiveSchemaContext.java

public EffectiveSchemaContext(List<DeclaredStatement<?>> rootDeclaredStatements,
        List<EffectiveStatement<?, ?>> rootEffectiveStatements) {
    this.rootDeclaredStatements = ImmutableList.copyOf(rootDeclaredStatements);
    this.rootEffectiveStatements = ImmutableList.copyOf(rootEffectiveStatements);

    Set<Module> modulesInit = new HashSet<>();
    for (EffectiveStatement<?, ?> rootEffectiveStatement : rootEffectiveStatements) {
        if (rootEffectiveStatement instanceof Module) {
            Module module = (Module) rootEffectiveStatement;
            modulesInit.add(module);//from   w ww . jav a 2s. c om
        }
    }
    this.modules = ImmutableSet.copyOf(modulesInit);

    final SetMultimap<URI, Module> nsMap = Multimaps.newSetMultimap(new TreeMap<URI, Collection<Module>>(),
            MODULE_SET_SUPPLIER);
    final SetMultimap<String, Module> nameMap = Multimaps
            .newSetMultimap(new TreeMap<String, Collection<Module>>(), MODULE_SET_SUPPLIER);

    for (Module m : modulesInit) {
        nameMap.put(m.getName(), m);
        nsMap.put(m.getNamespace(), m);
    }

    namespaceToModules = ImmutableSetMultimap.copyOf(nsMap);
    nameToModules = ImmutableSetMultimap.copyOf(nameMap);

    // :TODO
    // this.identifiersToSources =
    // ImmutableMap.copyOf(identifiersToSources);
    this.identifiersToSources = null;

}