guava/src/com/google/common/collect/Multimaps.java
public static <K, V> Multimap<K, V> newMultimap(
      Map<K, Collection<V>> map, final Supplier<? extends Collection<V>> factory) {
    return new CustomMultimap<>(map, factory);
  }
public static <K, V> Multimap<K, V> newMultimap(
      Map<K, Collection<V>> map, final Supplier<? extends Collection<V>> factory) {
    return new CustomMultimap<>(map, factory);
  }
Creates a new {@code Multimap} backed by {@code map}, whose internal value collections are
generated by {@code factory}.

<p><b>Warning: do not use</b> this method when the collections returned by {@code factory}
implement either {@link List} or {@code Set}! Use the more specific method {@link
#newListMultimap}, {@link #newSetMultimap} or {@link #newSortedSetMultimap} instead, to avoid
very surprising behavior from {@link Multimap#equals}.

<p>The {@code factory}-generated and {@code map} classes determine the multimap iteration
order. They also specify the behavior of the {@code equals}, {@code hashCode}, and {@code
toString} methods for the multimap and its returned views. However, the multimap's {@code get}
method returns instances of a different class than {@code factory.get()} does.

<p>The multimap is serializable if {@code map}, {@code factory}, the collections generated by
{@code factory}, and the multimap contents are all serializable.

<p>The multimap is not threadsafe when any concurrent operations update the multimap, even if
{@code map} and the instances generated by {@code factory} are. Concurrent read operations will
work correctly. To allow concurrent update operations, wrap the multimap with a call to {@link
#synchronizedMultimap}.

<p>Call this method only when the simpler methods {@link ArrayListMultimap#create()}, {@link
HashMultimap#create()}, {@link LinkedHashMultimap#create()}, {@link
LinkedListMultimap#create()}, {@link TreeMultimap#create()}, and {@link
TreeMultimap#create(Comparator, Comparator)} won't suffice.

<p>Note: the multimap assumes complete ownership over of {@code map} and the collections
returned by {@code factory}. Those objects should not be manually updated and they should not
use soft, weak, or phantom references.

@param map place to store the mapping from each key to its corresponding values
@param factory supplier of new, empty collections that will each hold all values for a given
key
@throws IllegalArgumentException if {@code map} is not empty