Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 20 additions & 14 deletions guava/src/com/google/common/collect/ImmutableMultimap.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,43 +75,46 @@ public abstract class ImmutableMultimap<K, V> extends BaseImmutableMultimap<K, V
implements Serializable {

/**
* Returns an empty multimap.
* Returns an empty multimap of type {@code ImmutableListMultimap}.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand the desire for consistency here, but I don't think it's all that helpful to users to know that the returned value is an ImmutableListMultimap, given that it's empty. If they actually need an empty ImmutableListMultimap then they should call ImmutableListMultimap.of(). Unlike the overloads with two or more arguments, there isn't really any observable behaviour that shows that the returned object is an ImmutableListMultimap, apart from just calling instanceof.

*
* <p><b>Performance note:</b> the instance returned is a singleton.
*/
public static <K, V> ImmutableMultimap<K, V> of() {
return ImmutableListMultimap.of();
}

/** Returns an immutable multimap containing a single entry. */
/** Returns an immutable multimap of type {@code ImmutableListMultimap} containing a single entry. */

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment here.

public static <K, V> ImmutableMultimap<K, V> of(K k1, V v1) {
return ImmutableListMultimap.of(k1, v1);
}

/** Returns an immutable multimap containing the given entries, in order. */
/**
* Returns an immutable multimap of type {@code ImmutableListMultimap} containing the given entries,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here this is maybe a bit helpful, though again if users care whether it is an ImmutableListMultimap then they should use ImmutableListMultimap.of.

* in order.
*/
public static <K, V> ImmutableMultimap<K, V> of(K k1, V v1, K k2, V v2) {
return ImmutableListMultimap.of(k1, v1, k2, v2);
}

/**
* Returns an immutable multimap containing the given entries, in the "key-grouped" insertion
* order described in the <a href="#iteration">class documentation</a>.
* Returns an immutable multimap of type {@code ImmutableListMultimap} containing the given entries,
* in the "key-grouped" insertion order described in the <a href="#iteration">class documentation</a>.
*/
public static <K, V> ImmutableMultimap<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3) {
return ImmutableListMultimap.of(k1, v1, k2, v2, k3, v3);
}

/**
* Returns an immutable multimap containing the given entries, in the "key-grouped" insertion
* order described in the <a href="#iteration">class documentation</a>.
* Returns an immutable multimap of type {@code ImmutableListMultimap} containing the given entries,
* in the "key-grouped" insertion order described in the <a href="#iteration">class documentation</a>.
*/
public static <K, V> ImmutableMultimap<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4) {
return ImmutableListMultimap.of(k1, v1, k2, v2, k3, v3, k4, v4);
}

/**
* Returns an immutable multimap containing the given entries, in the "key-grouped" insertion
* order described in the <a href="#iteration">class documentation</a>.
* Returns an immutable multimap of type {@code ImmutableListMultimap} containing the given entries,
* in the "key-grouped" insertion order described in the <a href="#iteration">class documentation</a>.
*/
public static <K, V> ImmutableMultimap<K, V> of(
K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5) {
Expand Down Expand Up @@ -292,7 +295,9 @@ Builder<K, V> combine(Builder<K, V> other) {
return this;
}

/** Returns a newly-created immutable multimap. */
/**
* Returns a newly-created immutable multimap of type {@code ImmutableListMultimap}.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get the impression that the single-line format used previously would still fit in the 100-column limit? We should probably preserve that.

*/
public ImmutableMultimap<K, V> build() {
Collection<Map.Entry<K, Collection<V>>> mapEntries = builderMap.entrySet();
if (keyComparator != null) {
Expand All @@ -308,7 +313,8 @@ public ImmutableMultimap<K, V> build() {
*
* <p>Despite the method name, this method attempts to avoid actually copying the data when it is
* safe to do so. The exact circumstances under which a copy will or will not be performed are
* undocumented and subject to change.
* undocumented and subject to change. When the copy is performed then the method returns the data
* in immutable multimap of type {@code ImmutableListMultimap}.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: in an immutable multimap

*
* @throws NullPointerException if any key or value in {@code multimap} is null
*/
Expand All @@ -324,9 +330,9 @@ public static <K, V> ImmutableMultimap<K, V> copyOf(Multimap<? extends K, ? exte
}

/**
* Returns an immutable multimap containing the specified entries. The returned multimap iterates
* over keys in the order they were first encountered in the input, and the values for each key
* are iterated in the order they were encountered.
* Returns an immutable multimap of type {@code ImmutableListMultimap} containing the specified entries.
* The returned multimap iterates over keys in the order they were first encountered in the input,
* and the values for each key are iterated in the order they were encountered.
*
* @throws NullPointerException if any key, value, or entry is null
* @since 19.0
Expand Down