Code example for ImmutableSetMultimap.Builder

Methods: build, putAll

0
    assertEquals(ImmutableSet.of(1, 2, 3, 6, 7), multimap.get("foo"));
    assertEquals(ImmutableSet.of(4, 5), multimap.get("bar"));
    assertEquals(7, multimap.size());
  } 
 
  public void testBuilderPutAllWithDuplicates() { 
    ImmutableSetMultimap.Builder<String, Integer> builder
        = ImmutableSetMultimap.builder();
    builder.putAll("foo", 1, 2, 3);
    builder.putAll("bar", 4, 5);
    builder.putAll("foo", 1, 6, 7);
    ImmutableSetMultimap<String, Integer> multimap = builder.build();
    assertEquals(7, multimap.size());
  } 
 
  public void testBuilderPutWithDuplicates() { 
    ImmutableSetMultimap.Builder<String, Integer> builder
        = ImmutableSetMultimap.builder();
    builder.putAll("foo", 1, 2, 3);
    builder.putAll("bar", 4, 5);
    builder.put("foo", 1);
    ImmutableSetMultimap<String, Integer> multimap = builder.build();
    assertEquals(5, multimap.size());
  } 
 
  public void testBuilderPutAllMultimapWithDuplicates() { 
    Multimap<String, Integer> toPut = LinkedListMultimap.create();
    toPut.put("foo", 1);
    toPut.put("bar", 4);
    toPut.put("foo", 2);
    toPut.put("foo", 1);
    toPut.put("bar", 5);
    ImmutableSetMultimap.Builder<String, Integer> builder
        = ImmutableSetMultimap.builder();
    builder.putAll(toPut);
    ImmutableSetMultimap<String, Integer> multimap = builder.build();
    assertEquals(4, multimap.size());
  } 
 
  public void testBuilderPutNullKey() { 
    Multimap<String, Integer> toPut = LinkedListMultimap.create();
Experience pair programming with AI  Get Codota for Java