GuavaCollectors { public static <T, K, U> Collector<T, ?, ImmutableBiMap<K, U>> toImmutableBiMap( Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends U> valueMapper, BinaryOperator<U> mergeFunction) { return new BiMapCollector<T, K, U, ImmutableBiMap<K, U>>(keyMapper, valueMapper, mergeFunction) { @Override public Function<BiMap<K, U>, ImmutableBiMap<K, U>> finisher() { return map -> { ImmutableBiMap.Builder<K, U> builder = ImmutableBiMap .builder(); return builder.putAll(map).build(); }; } @Override public Set<Characteristics> characteristics() { return CharacteristicSets.EMPTY; } }; } 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 testDuplicatedImmutableBiMapEntryWithMergeFunction() { ImmutableBiMap<String, Integer> biMap = Stream.of(10, 10).collect( GuavaCollectors.toImmutableBiMap(Object::toString, Function.identity(), (existing, newValue) -> existing)); Truth.assertThat(biMap).containsEntry("10", 10); Truth.assertThat(biMap).hasSize(1); }