@Test(dataProvider = "groupByWithException", expectedExceptions = { IllegalArgumentException.class }) public <K, V> void testGroupByWithException(Collection<V> list, Closure<K, V> closure) { CollectionUtils.groupBy(list, closure); }
public static <K, V> Map<K, List<V>> groupBy(Collection<V> list, Closure<K, V> closure) { if (null == closure) { throw new IllegalArgumentException("closure must not be null!"); } Map<K, List<V>> ret = new HashMap<K, List<V>>(); if (null != list) { for (V v : list) { K k = closure.execute(v); if (!ret.containsKey(k)) { ret.put(k, new ArrayList<V>()); } ret.get(k).add(v); } } return ret; }
CollectionUtils { public static <K, V> Map<K, List<V>> groupBy(Collection<V> list, Closure<K, V> closure) { if (null == closure) { throw new IllegalArgumentException("closure must not be null!"); } Map<K, List<V>> ret = new HashMap<K, List<V>>(); if (null != list) { for (V v : list) { K k = closure.execute(v); if (!ret.containsKey(k)) { ret.put(k, new ArrayList<V>()); } ret.get(k).add(v); } } return ret; } }
CollectionUtils { public static <K, V> Map<K, List<V>> groupBy(Collection<V> list, Closure<K, V> closure) { if (null == closure) { throw new IllegalArgumentException("closure must not be null!"); } Map<K, List<V>> ret = new HashMap<K, List<V>>(); if (null != list) { for (V v : list) { K k = closure.execute(v); if (!ret.containsKey(k)) { ret.put(k, new ArrayList<V>()); } ret.get(k).add(v); } } return ret; }  }
CollectionUtils { public static <K, V> Map<K, List<V>> groupBy(Collection<V> list, Closure<K, V> closure) { if (null == closure) { throw new IllegalArgumentException("closure must not be null!"); } Map<K, List<V>> ret = new HashMap<K, List<V>>(); if (null != list) { for (V v : list) { K k = closure.execute(v); if (!ret.containsKey(k)) { ret.put(k, new ArrayList<V>()); } ret.get(k).add(v); } } return ret; }  static Map<K, List<V>> groupBy(Collection<V> list, Closure<K, V> closure); static Map<K, V> overrideGroupBy(Collection<V> list, Closure<K, V> closure); static List<O> collect(Collection<I> list, Closure<O, I> closure); static List<O> collectSome(Collection<I> list, Closure<O, I> closure); static Set<O> collectUnique(Collection<I> list, Closure<O, I> closure); static List<V> subList(List<V> list, int startIndex, int count); @SuppressWarnings({ "unchecked", "rawtypes" }) static void mergePropertiesIntoMap(Properties props, Map map); }
CollectionUtils { public static <K, V> Map<K, List<V>> groupBy(Collection<V> list, Closure<K, V> closure) { if (null == closure) { throw new IllegalArgumentException("closure must not be null!"); } Map<K, List<V>> ret = new HashMap<K, List<V>>(); if (null != list) { for (V v : list) { K k = closure.execute(v); if (!ret.containsKey(k)) { ret.put(k, new ArrayList<V>()); } ret.get(k).add(v); } } return ret; }  static Map<K, List<V>> groupBy(Collection<V> list, Closure<K, V> closure); static Map<K, V> overrideGroupBy(Collection<V> list, Closure<K, V> closure); static List<O> collect(Collection<I> list, Closure<O, I> closure); static List<O> collectSome(Collection<I> list, Closure<O, I> closure); static Set<O> collectUnique(Collection<I> list, Closure<O, I> closure); static List<V> subList(List<V> list, int startIndex, int count); @SuppressWarnings({ "unchecked", "rawtypes" }) static void mergePropertiesIntoMap(Properties props, Map map);  }