Looking at 'forEach' and other iterating functions it boils down to this:
if (object == null) return new ArrayList().iterator();
if (object instanceof Iterable) return ((Iterable<?>)object).iterator();
if (object instanceof Iterator) return (Iterator<?>)object;
if (object.getClass().isArray()) return new ResettableIteratorOnArray<Object>((Object[])object);
if (object instanceof Map) return ((Map<?,?>)object).values().iterator();
overloading 'forEach' with each of these (except the null) is far better
practice as it will give compile time errors instead of runtime and will
simplify the code. Basically each implementation can simply point to an
'forEach(Iterator<?> iterator)'
A lot of tedium for sure. As the maintainer, if you're on board I am willing to
throw in some effort
Original issue reported on code.google.com by christia...@gmail.com on 16 May 2013 at 4:50
Original issue reported on code.google.com by
christia...@gmail.com
on 16 May 2013 at 4:50