@Test public void testSame() { Collection coll = Arrays.asList(item1, item2); assertTrue("Comparing identical collections should be return true", CollectionUtils.compareCollectionContents(coll, coll)); }
public static <C extends Collection> boolean compareCollectionContents(C c1, C c2) { if (c1.size() != c2.size()) { return false; } else { boolean allMatched = true; for (Object o : c1) { if (!c2.contains(o)) { allMatched = false; break; } } for (Object o : c2) { if (!c1.contains(o)) { allMatched = false; break; } } return allMatched; } }
CollectionUtils { public static <C extends Collection> boolean compareCollectionContents(C c1, C c2) { if (c1.size() != c2.size()) { return false; } else { boolean allMatched = true; for (Object o : c1) { if (!c2.contains(o)) { allMatched = false; break; } } for (Object o : c2) { if (!c1.contains(o)) { allMatched = false; break; } } return allMatched; } } }
CollectionUtils { public static <C extends Collection> boolean compareCollectionContents(C c1, C c2) { if (c1.size() != c2.size()) { return false; } else { boolean allMatched = true; for (Object o : c1) { if (!c2.contains(o)) { allMatched = false; break; } } for (Object o : c2) { if (!c1.contains(o)) { allMatched = false; break; } } return allMatched; } }  }
CollectionUtils { public static <C extends Collection> boolean compareCollectionContents(C c1, C c2) { if (c1.size() != c2.size()) { return false; } else { boolean allMatched = true; for (Object o : c1) { if (!c2.contains(o)) { allMatched = false; break; } } for (Object o : c2) { if (!c1.contains(o)) { allMatched = false; break; } } return allMatched; } }  static boolean compareCollectionContents(C c1, C c2); }
CollectionUtils { public static <C extends Collection> boolean compareCollectionContents(C c1, C c2) { if (c1.size() != c2.size()) { return false; } else { boolean allMatched = true; for (Object o : c1) { if (!c2.contains(o)) { allMatched = false; break; } } for (Object o : c2) { if (!c1.contains(o)) { allMatched = false; break; } } return allMatched; } }  static boolean compareCollectionContents(C c1, C c2);  }