/** * Adapts the given Iterator as an Iterable object for use within a for each loop. * * @param <T> the class type of the Iterator elements. * @param iterator the Iterator to adapt as an Iterable object. * @return an Iterable instance of the Iterator. * @see java.lang.Iterable * @see java.util.Iterator */ @NonNull public static <T> Iterable<T> iterable(@Nullable Iterator<T> iterator) { return () -> nullSafeIterator(iterator); }
/** * Adapts the given Iterator as an Iterable object for use within a for each loop. * * @param <T> the class type of the Iterator elements. * @param iterator the Iterator to adapt as an Iterable object. * @return an Iterable instance of the Iterator. * @see java.lang.Iterable * @see java.util.Iterator */ @NonNull public static <T> Iterable<T> iterable(@Nullable Iterator<T> iterator) { return () -> nullSafeIterator(iterator); }