New Collections interface - Sized
Stephen Colebourne
scolebourne at joda.org
Fri Apr 23 09:23:03 UTC 2021
Hi all,
While a discussion on ReversibleCollection is going on, I'd like to
raise the interface I've always found most missing from the framework
- Sized
public interface Sized {
int size();
default boolean isEmpty() {
return size() == 0;
}
default boolean isNotEmpty() {
return !isEmpty();
}
}
This would be applied to Collection and Map, providing a missing
unification. Anything else that has a size could also be retrofitted,
such as String. Ideally arrays too, but that could come later. Note
that Iterable would not implement it.
WDYT?
Stephen
More information about the core-libs-dev
mailing list