CollectionUtils { public static <T> Collection<T> remove(Collection<T> coll, final String field, final Object... removes) { if (coll == null || coll.size() == 0 || removes == null || removes.length == 0) return coll; Collection<T> needRemoved = new LinkedList<>(); try { for (T c : coll) if (canRemove(field, c, removes)) needRemoved.add(c); } catch (Exception e) { LOGGER.error(ExceptionUtils.errorInfo(e)); throw new RuntimeException(e); } coll.removeAll(needRemoved); return needRemoved; } private  CollectionUtils(); static List<String> removeAllByStrWithSeparator(List<String> originList,
                                                           String strWithSeparator, String separator); static Object[] intersection(Object[] a, Object[] b); static Collection<T> intersection(Collection<T> a, Collection<T> b); static Object getDuplicate(Collection<E> coll, E o, String field, Class fieldClass); static Object getDuplicate(Collection<E> coll, E o, String fieldName,
                                          Class fieldClass, Class elementClass); static Collection<T> remove(Collection<T> coll, final String field, final Object... removes); static int getNthNumberMin(int[] arr, int n); static int getNthNumberMax(int[] arr, int n); static Map<Y, Map<X, Z>> exchangeKeys(Map<X, Map<Y, Z>> map); static String join(T[] arr, String separator); static String join(Collection<T> list, String separator);  }
@Test public void removeCollTest() { A _a = new A(1, "2", 3); A _b = new A(1, "a", 3); A _c = new A(1, "!", 3); LinkedList<A> aList = new LinkedList<>(); aList.add(_a); aList.add(_b); aList.add(_c); try { aList.remove(0); aList.remove(2); aList.remove(1); assertEquals(0, aList.size()); } catch (Exception e) { assertTrue(e instanceof IndexOutOfBoundsException); } }