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
    An immutable builder for Multimap instances, letting you independently select the desired behaviors (for example, ordering) of the backing map and value-collections. Example:
    
     ListMultimap<UserId, ErrorResponse> errorsByUser =
         MultimapBuilder.linkedHashKeys().arrayListValues().build();
     SortedSetMultimap<String, Method> methodsForName =
         MultimapBuilder.treeKeys().treeSetValues(this::compareMethods).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