-
Notifications
You must be signed in to change notification settings - Fork 11.1k
5888: Improve Javadoc in ImmutableMultimap #5890
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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}. | ||
| * | ||
| * <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. */ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| * 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) { | ||
|
|
@@ -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}. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) { | ||
|
|
@@ -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}. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
| */ | ||
|
|
@@ -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 | ||
|
|
||
There was a problem hiding this comment.
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 emptyImmutableListMultimapthen they should callImmutableListMultimap.of(). Unlike the overloads with two or more arguments, there isn't really any observable behaviour that shows that the returned object is anImmutableListMultimap, apart from just callinginstanceof.