/** * Builds an {@link Iterable} for a given array. It is (un)necessarily ugly because we have to deal with array of primitives. * * @param object a given array * @return an {@code Iterable} providing iterators over the array */ @SuppressWarnings({ "unchecked", "rawtypes" }) // Reflection is used to ensure the correct types are used public static Iterable<?> iterableFromArray(Object object) { return new ArrayIterable( accessorFromArray( object ), object ); }
/** * Builds an {@link Iterator} for a given array. It is (un)necessarily ugly because we have to deal with array of primitives. * * @param object a given array * @return an {@code Iterator} iterating over the array */ @SuppressWarnings({ "unchecked", "rawtypes" }) // Reflection is used to ensure the correct types are used public static Iterator<?> iteratorFromArray(Object object) { return new ArrayIterator( accessorFromArray( object ), object ); }