### Question:
GuavaCollectors { public static <K, V> BiCollector<K, V, ImmutableMap<K, V>> toImmutableMap() { return ImmutableMap::toImmutableMap; } private  GuavaCollectors(); static BiCollector<K, V, ImmutableMap<K, V>> toImmutableMap(); static BiCollector<K, V, ImmutableMap<K, V>> toImmutableMap(
      BinaryOperator<V> valueMerger); static Collector<V, ?, ImmutableMap<K, V>> indexingBy(
      Function<? super V, ? extends K> indexingFunction); static BiCollector<K, V1, ImmutableMap<K, V>> toImmutableMap(
      Collector<V1, ?, V> valueCollector); static BiCollector<K, V, ImmutableSortedMap<K, V>> toImmutableSortedMap(
      Comparator<? super K> comparator, BinaryOperator<V> valueMerger); static BiCollector<K, V, ImmutableSortedMap<K, V>> toImmutableSortedMap(
      Comparator<? super K> comparator); static BiCollector<K, V, M> toMultimap(
      Supplier<M> multimapSupplier); static BiCollector<K, V, ImmutableListMultimap<K, V>> toImmutableListMultimap(); static BiCollector<K, T, ImmutableListMultimap<K, V>> flatteningToImmutableListMultimap(
          Function<? super T, ? extends Stream<? extends V>> flattener); static BiCollector<K, V, ImmutableSetMultimap<K, V>> toImmutableSetMultimap(); static BiCollector<K, T, ImmutableSetMultimap<K, V>> flatteningToImmutableSetMultimap(
          Function<? super T, ? extends Stream<? extends V>> flattener); static BiCollector<K, V, ImmutableMultiset<K>> toImmutableMultiset(
      ToIntFunction<? super V> countFunction); static BiCollector<K, V, ImmutableBiMap<K, V>> toImmutableBimap(); static BiCollector<R, BiStream<? extends C, ? extends V>, ImmutableTable<R, C, V>> toImmutableTable();  }### Answer:
@Test public void testToImmutableMap_valuesCollected() { ImmutableList<Town> towns = ImmutableList.of(new Town("WA", 100), new Town("WA", 50), new Town("IL", 200)); assertThat( BiStream.from(towns, Town::getState, town -> town) .collect(toImmutableMap(summingInt(Town::getPopulation)))) .containsExactly("WA", 150, "IL", 200) .inOrder(); }
@Test public void testToImmutableMap_keyEncounterOrderRetainedThroughValueCollector() { ImmutableList<Town> towns = ImmutableList.of( new Town("WA", 1), new Town("FL", 2), new Town("WA", 3), new Town("IL", 4), new Town("AZ", 5), new Town("OH", 6), new Town("IN", 7), new Town("CA", 8), new Town("CA", 9)); assertThat( BiStream.from(towns, Town::getState, town -> town) .collect(toImmutableMap(summingInt(Town::getPopulation)))) .containsExactly("WA", 4, "FL", 2, "IL", 4, "AZ", 5, "OH", 6, "IN", 7, "CA", 17) .inOrder(); }
@Test public void testToImmutableMap_empty() { ImmutableList<Town> towns = ImmutableList.of(); assertThat( BiStream.from(towns, Town::getState, town -> town) .collect(toImmutableMap(summingInt(Town::getPopulation)))) .isEmpty(); }
@Test public void testToImmutableMap_covariance() { ImmutableMap<Object, String> map = BiStream.of(1, "one").collect(toImmutableMap()); assertThat(map).containsExactly(1, "one"); }