Here's a quote from the class-level javadoc of ImmutableMultimap:
Warning: avoid direct usage of ImmutableMultimap as a type (as with Multimap itself). Prefer subtypes such as ImmutableSetMultimap or ImmutableListMultimap, which have well-defined Multimap.equals(java.lang.Object) semantics, thus avoiding a common source of bugs and confusion.
In this regard, it seems unfortunate that ImmutableMultimap.builder().build() returns ImmutableMultimap. Is this an ImmutableSetMultimap or a ImmutableListMultimap? At least the Javadoc should be clear about that. Or better yet:
ImmutableMultimap.Builder should be an abstract class, to avoid the confusion (this would be a breaking change)
ImmutableMultimap.builder() should return ImmutableListMultimap.Builder (probably not a breaking change)
- For clarity, consider adding explicit methods
ImmutableMultimap.setMultimapBuilder() and ImmutableMultimap.listMultimapBuilder() (not a breaking change)
https://guava.dev/releases/snapshot-jre/api/docs/com/google/common/collect/ImmutableMultimap.html
https://guava.dev/releases/snapshot-jre/api/docs/com/google/common/collect/ImmutableMultimap.Builder.html
Here's a quote from the class-level javadoc of
ImmutableMultimap:In this regard, it seems unfortunate that
ImmutableMultimap.builder().build()returnsImmutableMultimap. Is this anImmutableSetMultimapor aImmutableListMultimap? At least the Javadoc should be clear about that. Or better yet:ImmutableMultimap.Buildershould be anabstractclass, to avoid the confusion (this would be a breaking change)ImmutableMultimap.builder()should returnImmutableListMultimap.Builder(probably not a breaking change)ImmutableMultimap.setMultimapBuilder()andImmutableMultimap.listMultimapBuilder()(not a breaking change)https://guava.dev/releases/snapshot-jre/api/docs/com/google/common/collect/ImmutableMultimap.html
https://guava.dev/releases/snapshot-jre/api/docs/com/google/common/collect/ImmutableMultimap.Builder.html