@Test void shouldStreamAnEnumeration() { Enumeration<String> enumeration = Collections.enumeration(Arrays.asList("RED", "BLUE", "GREEN")); List<String> result = enumerationStream(enumeration).map(String::toLowerCase).collect(Collectors.toList()); assertEquals(Arrays.asList("red", "blue", "green"), result); }
public static <T> Stream<T> enumerationStream(Enumeration<T> enumeration) { requireNonNull(enumeration); return StreamSupport.stream(new Spliterators.AbstractSpliterator<T>(Long.MAX_VALUE, Spliterator.ORDERED) { @Override public boolean tryAdvance(Consumer<? super T> action) { if (enumeration.hasMoreElements()) { action.accept(enumeration.nextElement()); return true; } return false; } @Override public void forEachRemaining(Consumer<? super T> action) { while (enumeration.hasMoreElements()) { action.accept(enumeration.nextElement()); } } }, false); }
Streams { public static <T> Stream<T> enumerationStream(Enumeration<T> enumeration) { requireNonNull(enumeration); return StreamSupport.stream(new Spliterators.AbstractSpliterator<T>(Long.MAX_VALUE, Spliterator.ORDERED) { @Override public boolean tryAdvance(Consumer<? super T> action) { if (enumeration.hasMoreElements()) { action.accept(enumeration.nextElement()); return true; } return false; } @Override public void forEachRemaining(Consumer<? super T> action) { while (enumeration.hasMoreElements()) { action.accept(enumeration.nextElement()); } } }, false); } }
Streams { public static <T> Stream<T> enumerationStream(Enumeration<T> enumeration) { requireNonNull(enumeration); return StreamSupport.stream(new Spliterators.AbstractSpliterator<T>(Long.MAX_VALUE, Spliterator.ORDERED) { @Override public boolean tryAdvance(Consumer<? super T> action) { if (enumeration.hasMoreElements()) { action.accept(enumeration.nextElement()); return true; } return false; } @Override public void forEachRemaining(Consumer<? super T> action) { while (enumeration.hasMoreElements()) { action.accept(enumeration.nextElement()); } } }, false); } private  Streams(); }
Streams { public static <T> Stream<T> enumerationStream(Enumeration<T> enumeration) { requireNonNull(enumeration); return StreamSupport.stream(new Spliterators.AbstractSpliterator<T>(Long.MAX_VALUE, Spliterator.ORDERED) { @Override public boolean tryAdvance(Consumer<? super T> action) { if (enumeration.hasMoreElements()) { action.accept(enumeration.nextElement()); return true; } return false; } @Override public void forEachRemaining(Consumer<? super T> action) { while (enumeration.hasMoreElements()) { action.accept(enumeration.nextElement()); } } }, false); } private  Streams(); static OutputStream nullOutputStream(); static PrintStream nullPrintStream(); static Stream<T> enumerationStream(Enumeration<T> enumeration); }
Streams { public static <T> Stream<T> enumerationStream(Enumeration<T> enumeration) { requireNonNull(enumeration); return StreamSupport.stream(new Spliterators.AbstractSpliterator<T>(Long.MAX_VALUE, Spliterator.ORDERED) { @Override public boolean tryAdvance(Consumer<? super T> action) { if (enumeration.hasMoreElements()) { action.accept(enumeration.nextElement()); return true; } return false; } @Override public void forEachRemaining(Consumer<? super T> action) { while (enumeration.hasMoreElements()) { action.accept(enumeration.nextElement()); } } }, false); } private  Streams(); static OutputStream nullOutputStream(); static PrintStream nullPrintStream(); static Stream<T> enumerationStream(Enumeration<T> enumeration);  }