@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(); }
public void testAsMultimapWhenEmpty() { ImmutableMap<String, Integer> map = ImmutableMap.of(); ImmutableSetMultimap<String, Integer> expected = ImmutableSetMultimap.of(); assertEquals(expected, map.asMultimap()); }
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()); }
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); }
/** * 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); }
@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(); }
/** * 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); }
/** * 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); }
/** * 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); }
/** 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(); }
public void testAsMultimapWhenEmpty() { ImmutableMap<String, Integer> map = ImmutableMap.of(); ImmutableSetMultimap<String, Integer> expected = ImmutableSetMultimap.of(); assertEquals(expected, map.asMultimap()); }
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()); }
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); }
HealthMonitors healthMonitors = lbaasApi.listHealthMonitors(PaginationOptions.Builder.queryParameters(ImmutableMap.of("tenant_id", subnet.getTenantId()).asMultimap())); assertNotNull(healthMonitors); assertFalse(healthMonitors.isEmpty());
Pools pools = lbaasApi.listPools(PaginationOptions.Builder.queryParameters(ImmutableMap.of("name", "jclouds-lbaas-test-pool").asMultimap())); assertNotNull(pools); assertFalse(pools.isEmpty());
Members members = lbaasApi.listMembers(PaginationOptions.Builder.queryParameters(ImmutableMap.of("tenant_id", subnet.getTenantId()).asMultimap())); assertNotNull(members); assertFalse(members.isEmpty());
VIPs vips = lbaasApi.listVIPs(PaginationOptions.Builder.queryParameters(ImmutableMap.of("tenant_id", subnet.getTenantId()).asMultimap())); assertNotNull(vips); assertFalse(vips.isEmpty());