### Question:
CollectionUtils { public static <T> Map<Object, Collection> classify(Collection<T> srcCollection, ClassifyFilter classifyFilter) { Map<Object, Collection> ret = new HashMap<>(); for (Object o : srcCollection) { Object key = classifyFilter.filter(o); Collection coll = ret.get(key); if (coll == null) { if (srcCollection instanceof List) { coll = new ArrayList(); } else if (srcCollection instanceof Set) { coll = new HashSet(); } else { throw new RuntimeException(Info.get(CollectionUtils.class, R.COLLECTION_TYPE_NOT_SUPPORTED1, srcCollection.getClass())); } ret.put(key, coll); } coll.add(o); } return ret; }  static LinkedList<Object> toLinkedList(Object[] array); static boolean contains(Collection collection, Class clazz); static Object getFirstMatch(Object[] collection, Class clazz); static Object getFirstMatch(List collection, Class clazz); static Map<Object, Collection> classify(Collection<T> srcCollection, ClassifyFilter classifyFilter); static T constructCollectionByType(Class collectionType); static Collection<T> sortCollection(Collection<T> collection, Comparator<T> comparator);  }### Answer:
@Test public void testClassify() { List<TestBean> list = new ArrayList<TestBean>() { { add(new TestBean("a", "a1")); add(new TestBean("a", "a2")); add(new TestBean("a", "a3")); add(new TestBean("b", "b1")); add(new TestBean("b", "b2")); add(new TestBean("b", "b3")); } }; Map<Object, Collection> classify = CollectionUtils.classify(list, (ClassifyFilter<TestBean>) TestBean::getKey); for (Object k : classify.keySet()) { System.out.println(k); System.out.println(classify.get(k)); } Collection<TestBean> ca = classify.get("a"); Assertions.assertNotNull(ca); Assertions.assertEquals(3, ca.size()); for (TestBean e : ca) { Assertions.assertEquals("a", e.getValue().substring(0, 1)); } Collection<TestBean> cb = classify.get("b"); Assertions.assertNotNull(cb); Assertions.assertEquals(3, cb.size()); for (TestBean e : cb) { Assertions.assertEquals("b", e.getValue().substring(0, 1)); } }