paulk-asert commented on code in PR #665:
URL: 
https://github.com/apache/commons-collections/pull/665#discussion_r2621400525


##########
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
+     * to a collector MultiValuedMap. If you are trying to create an
+     * inverse multimap of the same kind as the original, consider using
+     * {@link MultiValuedMap#inverted()}.
+     *
+     * @param source take key-to-value mappings from here
+     * @param collector add value-to-key mappings here
+     * @param <K> the collector key type
+     * @param <V> the collector value type
+     * @param <M> the collector multimap
+     * @return the updated collector
+     */
+    public static <K, V, M extends MultiValuedMap<K, V>>
+    M invertInto(MultiValuedMap<? extends V, ? extends K> source, M collector) 
{

Review Comment:
   Guava has similar methods to what is proposed here. It uses `invertFrom` as 
the utility method and `inverse` as the instance method. I think `invert` and 
`invertMerge` have some benefits. I'll ponder a change and convert `collector` 
to `target` or similar. Hmmm.. `CollectionUtils#collect` uses `inputCollection` 
and `outputCollection`. Maybe that is the way to go.



-- 
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]

Reply via email to