General in Google Multimap

Do you have a reason why MultiMap is not completely shared?

containsEntry(Object key, Object value) containsKey(Object key) remove(Object key, Object value) removeAll(Object key) 
+4
source share
2 answers

Check out this answer , which is also true for Guava Multimap. Also, you may need to read the Kevin Bourrillion blog entry (it will output the Guava host) explaining the same problem (note that add uses a generic type E ):

The real difference is that add () can cause "damage" when called with the wrong type and contains () and remove () cannot.

Evenly, the Java Collection Framework Framework methods (and the Google Collection Library, too) never limit the types of their parameters unless it is necessary to prevent collection collection from being broken.

+4
source

My guess is because they need a similar interface for the original java.util.Map interface

+1
source

All Articles