GuavaCollectors { public static <T> Collector<T, ?, Multiset<T>> toMultiset() { return new MultisetCollector<T, Multiset<T>>() { @Override public Function<Multiset<T>, Multiset<T>> finisher() { return Function.identity(); } @Override public Set<Characteristics> characteristics() { return CharacteristicSets.IDENTITY; } }; } private  GuavaCollectors(); static Collector<T, ?, Table<R, C, V>> toTable(
            Function<? super T, ? extends R> rowMapper,
            Function<? super T, ? extends C> columnMapper,
            Function<? super T, ? extends V> valueMapper); static Collector<T, ?, Table<R, C, V>> toTable(
            Function<? super T, ? extends R> rowMapper,
            Function<? super T, ? extends C> columnMapper,
            Function<? super T, ? extends V> valueMapper,
            BinaryOperator<V> mergeFunction); static Collector<T, ?, BiMap<K, U>> toBiMap(
            Function<? super T, ? extends K> keyMapper,
            Function<? super T, ? extends U> valueMapper); static Collector<T, ?, BiMap<K, U>> toBiMap(
            Function<? super T, ? extends K> keyMapper,
            Function<? super T, ? extends U> valueMapper,
            BinaryOperator<U> mergeFunction); static Collector<T, ?, ImmutableBiMap<K, U>> toImmutableBiMap(
            Function<? super T, ? extends K> keyMapper,
            Function<? super T, ? extends U> valueMapper,
            BinaryOperator<U> mergeFunction); static Collector<T, ?, Multimap<K, U>> toMultimap(
            Function<? super T, ? extends K> keyMapper,
            Function<? super T, ? extends U> valueMapper); static Collector<T, ?, ImmutableMultimap<K, U>> toImmutableMultimap(
            Function<? super T, ? extends K> keyMapper,
            Function<? super T, ? extends U> valueMapper); static Collector<T, ?, Multiset<T>> toMultiset();  }
@Test public void testCollectToMultiset() { Multiset<String> multiset = Stream.of(1, 2).map(Object::toString).collect( GuavaCollectors.toMultiset()); Truth.assertThat(multiset).hasSize(2); Truth.assertThat(multiset).contains("1"); Truth.assertThat(multiset).contains("2"); }
@Test public void testDuplicatedMultisetEntry() { Multiset<String> multiset = Stream.of(10, 10).map(Object::toString).collect( GuavaCollectors.toMultiset()); Truth.assertThat(multiset).hasSize(2); Truth.assertThat(multiset.count("10")).isEqualTo(2); }