a-foundation/src/main/java/com/ajjpj/afoundation/collection/ACollectionHelper.java
public static <T, X, E extends Throwable> Map<X, List<T>> groupBy (List<T> coll, AFunction1<? super T, ? extends X, E> f) throws E {
        final Map<X, List<T>> result = new HashMap<>();
        for(T o: coll) {
            final X key = f.apply(o);
            List<T> perKey = result.get(key);
            if(perKey == null) {
                perKey = createEmptyListOfType (coll, false);
                result.put(key, perKey);
            }
            perKey.add(o);
        }
        return result;
    }
public static <T, X, E extends Throwable> Map<X, List<T>> groupBy (List<T> coll, AFunction1<? super T, ? extends X, E> f) throws E {
        final Map<X, List<T>> result = new HashMap<>();
        for(T o: coll) {
            final X key = f.apply(o);
            List<T> perKey = result.get(key);
            if(perKey == null) {
                perKey = createEmptyListOfType (coll, false);
                result.put(key, perKey);
            }
            perKey.add(o);
        }
        return result;
    }
Creates a Map from a collection. Each element's key is determined by applying a function to the element. All
elements with the same key are stored as that key's value in the returned Map.