[jOOQ/jOOQ#9864] Added some more iterable tools

This commit is contained in:
Lukas Eder 2021-11-03 16:31:48 +01:00
parent 820c09c56b
commit b065c9de88

View File

@ -5696,15 +5696,29 @@ final class Tools {
}
static final boolean isNotEmpty(Collection<?> collection) {
return collection != null && !collection.isEmpty();
return !isEmpty(collection);
}
static final boolean isEmpty(Collection<?> collection) {
return collection == null || collection.isEmpty();
}
static final boolean isNotEmpty(Iterable<?> it) {
return !isEmpty(it);
}
static final boolean isEmpty(Iterable<?> it) {
if (it == null)
return true;
else if (it instanceof Collection)
return isEmpty((Collection<?>) it);
Iterator<?> i = it.iterator();
return !i.hasNext();
}
static final boolean isNotEmpty(Object[] array) {
return array != null && array.length > 0;
return !isEmpty(array);
}
static final boolean isEmpty(Object[] array) {