in src/main/java/org/apache/commons/collections4/CollectionUtils.java [1906:1933]
public static boolean sizeIsEmpty(final Object object) {
if (object == null) {
return true;
}
if (object instanceof Collection<?>) {
return ((Collection<?>) object).isEmpty();
}
if (object instanceof Iterable<?>) {
return IterableUtils.isEmpty((Iterable<?>) object);
}
if (object instanceof Map<?, ?>) {
return ((Map<?, ?>) object).isEmpty();
}
if (object instanceof Object[]) {
return ((Object[]) object).length == 0;
}
if (object instanceof Iterator<?>) {
return !((Iterator<?>) object).hasNext();
}
if (object instanceof Enumeration<?>) {
return !((Enumeration<?>) object).hasMoreElements();
}
try {
return Array.getLength(object) == 0;
} catch (final IllegalArgumentException ex) {
throw new IllegalArgumentException("Unsupported object type: " + object.getClass().getName());
}
}