Top Description Inners Fields Constructors Methods
com.google.common.collect

public abstract Class MultimapBuilder<K0 extends @Nullable Object, V0 extends @Nullable Object>

extends Object
Class Inheritance
Known Direct Subclasses
com.google.common.collect.MultimapBuilder.ListMultimapBuilder, com.google.common.collect.MultimapBuilder.SetMultimapBuilder
Annotations
@GwtCompatible
@ElementTypesAreNonnullByDefault
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.
Static Imports
com.google.common.base.Preconditions.checkNotNull, com.google.common.collect.CollectPreconditions.checkNonnegative

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.

Author
Louis Wasserman
Since
16.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class
private static class
private static class
private static enum
public abstract static class
MultimapBuilder.ListMultimapBuilder<K0 extends @Nullable Object, V0 extends @Nullable Object>

A specialization of MultimapBuilder that generates ListMultimap instances.

public abstract static class
MultimapBuilder.MultimapBuilderWithKeys<
The upper bound on the key type of the generated multimap.
K0 extends @Nullable Object
>

An intermediate stage in a MultimapBuilder in which the key-value collection map implementation has been specified, but the value collection implementation has not.

public abstract static class
MultimapBuilder.SetMultimapBuilder<K0 extends @Nullable Object, V0 extends @Nullable Object>

A specialization of MultimapBuilder that generates SetMultimap instances.

public abstract static class
MultimapBuilder.SortedSetMultimapBuilder<K0 extends @Nullable Object, V0 extends @Nullable Object>

A specialization of MultimapBuilder that generates SortedSetMultimap instances.

private static class

Field Summary

Modifier and TypeField and Description
private static final int

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public abstract <K extends K0, V extends V0> Multimap<K, V>
build()

Returns a new, empty Multimap with the specified implementation.

public <K extends K0, V extends V0> Multimap<K, V>
build(Multimap<? extends K, ? extends V> multimap)

Returns a Multimap with the specified implementation, initialized with the entries of multimap.

public static <K0 extends Enum<K0>> MultimapBuilder.MultimapBuilderWithKeys<K0>
enumKeys(Class<K0> keyClass)

Uses an EnumMap to map keys to value collections.

public static MultimapBuilder.MultimapBuilderWithKeys<@Nullable Object>
hashKeys()

Uses a hash table to map keys to value collections.

public static MultimapBuilder.MultimapBuilderWithKeys<@Nullable Object>
hashKeys(int expectedKeys)

Uses a hash table to map keys to value collections, initialized to expect the specified number of keys.

public static MultimapBuilder.MultimapBuilderWithKeys<@Nullable Object>
linkedHashKeys()

Uses a hash table to map keys to value collections.

public static MultimapBuilder.MultimapBuilderWithKeys<@Nullable Object>
linkedHashKeys(int expectedKeys)

Uses an hash table to map keys to value collections, initialized to expect the specified number of keys.

public static MultimapBuilder.MultimapBuilderWithKeys<Comparable<T>>
treeKeys()

Uses a naturally-ordered TreeMap to map keys to value collections.

public static <K0 extends @Nullable Object> MultimapBuilder.MultimapBuilderWithKeys<K0>
treeKeys(Comparator<K0> comparator)

Uses a TreeMap sorted by the specified comparator to map keys to value collections.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait