Traversers { @Nonnull public static <T> Traverser<T> traverseArray(@Nonnull T[] array) { return new ArrayTraverser<>(array); } private  Traversers(); @SuppressWarnings("unchecked") @Nonnull static Traverser<T> empty(); @Nonnull static Traverser<T> singleton(@Nonnull T item); @Nonnull static Traverser<T> traverseIterator(@Nonnull Iterator<? extends T> iterator); @Nonnull static Traverser<T> traverseIterator(@Nonnull Iterator<? extends T> iterator, boolean ignoreNulls); @Nonnull static Traverser<T> traverseSpliterator(@Nonnull Spliterator<T> spliterator); @Nonnull static Traverser<T> traverseEnumeration(@Nonnull Enumeration<T> enumeration); @Nonnull static Traverser<T> traverseStream(@Nonnull Stream<T> stream); @Nonnull static Traverser<T> traverseIterable(@Nonnull Iterable<? extends T> iterable); @Nonnull static Traverser<T> traverseArray(@Nonnull T[] array); @SafeVarargs static Traverser<T> traverseItems(T... items); @Nonnull static Traverser<T> lazy(@Nonnull Supplier<Traverser<T>> supplierOfTraverser);  }
@Test public void when_traverseArray_then_seeAllItems() { validateTraversal(traverseArray(new Integer[] {1, 2})); }
@Test public void when_traverseArrayWithNull_then_skipNulls() { Traverser<Integer> trav = traverseArray(new Integer[] {1, null, 2}); assertEquals(1, (int) trav.next()); assertEquals(2, (int) trav.next()); assertNull(trav.next()); }