paulk-asert commented on code in PR #665:
URL:
https://github.com/apache/commons-collections/pull/665#discussion_r2621377853
##########
src/main/java/org/apache/commons/collections4/MultiMapUtils.java:
##########
@@ -170,6 +171,27 @@ public static boolean isEmpty(final MultiValuedMap<?, ?>
map) {
return map == null || map.isEmpty();
}
+ /**
+ * A utility method to invert the mappings from a source MultiValuedMap
Review Comment:
You could write a method that worked with ordinary maps. Given that ordinary
maps don't need the value to be a collection, there are multiple possible
semantics. One potential behavior would be to throw a runtime exception if
called with a map having a value that isn't a collection. Another semantic
might coerce the value into a singleton collection. Other libraries tend to
have factory methods for creating a multimap from an ordinary map - different
factory methods could provide different semantics. Then the invert method just
works with multimaps. Commons Collections already has such factory methods,
e.g. `HashSetValuedHashMap(Map)`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]