CollectionUtil { public static boolean containsNotNull(Collection<?> collection) throws NullPointerException { for (Object o : collection) { if (o != null) { return true; } } return false; }  static boolean containsNotNull(Collection<?> collection);  }
@Test public void testContainsNotNull() throws Exception { ArrayList<String> list = new ArrayList<>(); assertFalse(CollectionUtil.containsNotNull(list)); list.add(null); assertFalse(CollectionUtil.containsNotNull(list)); list.add(null); assertFalse(CollectionUtil.containsNotNull(list)); list.add("foo"); assertTrue(CollectionUtil.containsNotNull(list)); }