IterableUtils { public static <T> boolean isEmpty(Iterable<T> iterable) { Iterator<T> iterator = iterable.iterator(); try { return !iterator.hasNext(); } finally { closeQuietly(iterator); } }  @SuppressWarnings("unchecked") static List<T> toList(Iterable<? extends T> iterable); static List<T> toList(Iterator<T> iterator); @SuppressWarnings("unchecked") static Set<T> toSet(Iterable<? extends T> iterable); @SuppressWarnings("unchecked") static Set<T> toSet(T[] iterable); @SuppressWarnings("unchecked") static T[] toArray(Iterable<? extends T> iterable, Class<T> type); static int count(Iterable<T> iterable); static int count(Iterator<T> iterator); static boolean isEmpty(Iterable<T> iterable); static Iterable<T> toIterable(final T[] arr); static T single(final Iterable<? extends T> it); static T singleOrDefault(final Iterable<? extends T> it, T defaultValue); static String join(Iterable items, String sep); @SuppressWarnings("unchecked") static Iterable<Element> toElementIterable(Iterable<? extends Element> elements); static Map<String, T> toMapById(Iterable<T> elements); static T last(Iterable<T> iterable);  }
@Test public void testIsEmpty() { assertTrue(IterableUtils.isEmpty(Collections.emptyList())); assertFalse(IterableUtils.isEmpty(Collections.singletonList("junit"))); }