本文整理了Java中com.google.common.collect.ImmutableMap.asMultimap()
方法的一些代码示例,展示了ImmutableMap.asMultimap()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ImmutableMap.asMultimap()
方法的具体详情如下:
包路径:com.google.common.collect.ImmutableMap
类名称:ImmutableMap
方法名:asMultimap
[英]Returns a multimap view of the map.
[中]返回地图的多重地图视图。
代码示例来源:origin: google/guava
@Override
public Map<String, Collection<Integer>> create(Object... elements) {
ImmutableMap.Builder<String, Integer> builder = ImmutableMap.builder();
// assumes that each set is a singleton or less (as is done for the samples)
for (Object elem : elements) {
@SuppressWarnings("unchecked") // safe by generator contract
Entry<String, Collection<Integer>> entry = (Entry<String, Collection<Integer>>) elem;
Integer value = Iterables.getOnlyElement(entry.getValue());
builder.put(entry.getKey(), value);
}
return builder.build().asMultimap().asMap();
}
代码示例来源:origin: google/guava
public void testAsMultimapWhenEmpty() {
ImmutableMap<String, Integer> map = ImmutableMap.of();
ImmutableSetMultimap<String, Integer> expected = ImmutableSetMultimap.of();
assertEquals(expected, map.asMultimap());
}
代码示例来源:origin: google/guava
public void testAsMultimap() {
ImmutableMap<String, Integer> map =
ImmutableMap.of("one", 1, "won", 1, "two", 2, "too", 2, "three", 3);
ImmutableSetMultimap<String, Integer> expected =
ImmutableSetMultimap.of("one", 1, "won", 1, "two", 2, "too", 2, "three", 3);
assertEquals(expected, map.asMultimap());
}
代码示例来源:origin: google/guava
public void testAsMultimapCaches() {
ImmutableMap<String, Integer> map = ImmutableMap.of("one", 1);
ImmutableSetMultimap<String, Integer> multimap1 = map.asMultimap();
ImmutableSetMultimap<String, Integer> multimap2 = map.asMultimap();
assertEquals(1, multimap1.asMap().size());
assertSame(multimap1, multimap2);
}
代码示例来源:origin: prestodb/presto
/**
* Returns the input to output symbol mapping for the given source channel.
* A single input symbol can map to multiple output symbols, thus requiring a Multimap.
*/
public Multimap<Symbol, SymbolReference> outputSymbolMap(int sourceIndex)
{
return Multimaps.transformValues(FluentIterable.from(getOutputSymbols())
.toMap(outputToSourceSymbolFunction(sourceIndex))
.asMultimap()
.inverse(), Symbol::toSymbolReference);
}
代码示例来源:origin: com.google.guava/guava-testlib
@Override
public Map<String, Collection<Integer>> create(Object... elements) {
ImmutableMap.Builder<String, Integer> builder = ImmutableMap.builder();
// assumes that each set is a singleton or less (as is done for the samples)
for (Object elem : elements) {
@SuppressWarnings("unchecked") // safe by generator contract
Entry<String, Collection<Integer>> entry = (Entry<String, Collection<Integer>>) elem;
Integer value = Iterables.getOnlyElement(entry.getValue());
builder.put(entry.getKey(), value);
}
return builder.build().asMultimap().asMap();
}
代码示例来源:origin: prestosql/presto
/**
* Returns the input to output symbol mapping for the given source channel.
* A single input symbol can map to multiple output symbols, thus requiring a Multimap.
*/
public Multimap<Symbol, SymbolReference> outputSymbolMap(int sourceIndex)
{
return Multimaps.transformValues(FluentIterable.from(getOutputSymbols())
.toMap(outputToSourceSymbolFunction(sourceIndex))
.asMultimap()
.inverse(), Symbol::toSymbolReference);
}
代码示例来源:origin: io.prestosql/presto-main
/**
* Returns the input to output symbol mapping for the given source channel.
* A single input symbol can map to multiple output symbols, thus requiring a Multimap.
*/
public Multimap<Symbol, SymbolReference> outputSymbolMap(int sourceIndex)
{
return Multimaps.transformValues(FluentIterable.from(getOutputSymbols())
.toMap(outputToSourceSymbolFunction(sourceIndex))
.asMultimap()
.inverse(), Symbol::toSymbolReference);
}
代码示例来源:origin: uk.co.nichesolutions.presto/presto-main
/**
* Returns the input to output symbol mapping for the given source channel.
* A single input symbol can map to multiple output symbols, thus requiring a Multimap.
*/
public Multimap<Symbol, QualifiedNameReference> outputSymbolMap(int sourceIndex)
{
return Multimaps.transformValues(FluentIterable.from(getOutputSymbols())
.toMap(outputToSourceSymbolFunction(sourceIndex))
.asMultimap()
.inverse(), Symbol::toQualifiedNameReference);
}
代码示例来源:origin: com.google.dagger/dagger-compiler
/** All bindings for {@link #key()}, indexed by the component that owns the binding. */
final ImmutableSetMultimap<TypeElement, ? extends Binding> allBindings() {
return !allMembersInjectionBindings().isEmpty()
? allMembersInjectionBindings().asMultimap()
: allContributionBindings();
}
代码示例来源:origin: com.google.guava/guava-tests
public void testAsMultimapWhenEmpty() {
ImmutableMap<String, Integer> map = ImmutableMap.of();
ImmutableSetMultimap<String, Integer> expected = ImmutableSetMultimap.of();
assertEquals(expected, map.asMultimap());
}
代码示例来源:origin: com.google.guava/guava-tests
public void testAsMultimap() {
ImmutableMap<String, Integer> map = ImmutableMap.of(
"one", 1, "won", 1, "two", 2, "too", 2, "three", 3);
ImmutableSetMultimap<String, Integer> expected = ImmutableSetMultimap.of(
"one", 1, "won", 1, "two", 2, "too", 2, "three", 3);
assertEquals(expected, map.asMultimap());
}
代码示例来源:origin: com.google.guava/guava-tests
public void testAsMultimapCaches() {
ImmutableMap<String, Integer> map = ImmutableMap.of("one", 1);
ImmutableSetMultimap<String, Integer> multimap1 = map.asMultimap();
ImmutableSetMultimap<String, Integer> multimap2 = map.asMultimap();
assertEquals(1, multimap1.asMap().size());
assertSame(multimap1, multimap2);
}
代码示例来源:origin: apache/jclouds
HealthMonitors healthMonitors = lbaasApi.listHealthMonitors(PaginationOptions.Builder.queryParameters(ImmutableMap.of("tenant_id", subnet.getTenantId()).asMultimap()));
assertNotNull(healthMonitors);
assertFalse(healthMonitors.isEmpty());
代码示例来源:origin: apache/jclouds
Pools pools = lbaasApi.listPools(PaginationOptions.Builder.queryParameters(ImmutableMap.of("name", "jclouds-lbaas-test-pool").asMultimap()));
assertNotNull(pools);
assertFalse(pools.isEmpty());
代码示例来源:origin: apache/jclouds
Members members = lbaasApi.listMembers(PaginationOptions.Builder.queryParameters(ImmutableMap.of("tenant_id", subnet.getTenantId()).asMultimap()));
assertNotNull(members);
assertFalse(members.isEmpty());
代码示例来源:origin: apache/jclouds
VIPs vips = lbaasApi.listVIPs(PaginationOptions.Builder.queryParameters(ImmutableMap.of("tenant_id", subnet.getTenantId()).asMultimap()));
assertNotNull(vips);
assertFalse(vips.isEmpty());
内容来源于网络,如有侵权,请联系作者删除!