Class MultimapBuilder<K0 extends @Nullable java.lang.Object,​V0 extends @Nullable java.lang.Object>

  • Type Parameters:
    K0 - An upper bound on the key type of the generated multimap.
    V0 - An upper bound on the value type of the generated multimap.
    Direct Known Subclasses:
    MultimapBuilder.ListMultimapBuilder, MultimapBuilder.SetMultimapBuilder

    @GwtCompatible
    public abstract class MultimapBuilder<K0 extends @Nullable java.lang.Object,​V0 extends @Nullable java.lang.Object>
    extends java.lang.Object
    A builder for a multimap implementation that allows customization of the backing map and value collection implementations used in a particular multimap.

    This can be used to easily configure multimap data structure implementations not provided explicitly in com.google.common.collect, for example:

    
     ListMultimap<String, Integer> treeListMultimap =
         MultimapBuilder.treeKeys().arrayListValues().build();
     SetMultimap<Integer, MyEnum> hashEnumMultimap =
         MultimapBuilder.hashKeys().enumSetValues(MyEnum.class).build();
     

    MultimapBuilder instances are immutable. Invoking a configuration method has no effect on the receiving instance; you must store and use the new builder instance it returns instead.

    The generated multimaps are serializable if the key and value types are serializable, unless stated otherwise in one of the configuration methods.

    Since:
    16.0
    Author:
    Louis Wasserman