SingletonSpliterator implements Spliterator<T> { @SuppressWarnings("unchecked") @Override public void forEachRemaining(Consumer<? super T> action) { requireNonNull(action); if (!consumed) { action.accept((T) item); consumed = true; } } SingletonSpliterator(Object item, int additionalCharacteristics); @Override Spliterator<T> trySplit(); @SuppressWarnings("unchecked") @Override void forEachRemaining(Consumer<? super T> action); @Override boolean tryAdvance(Consumer<? super T> action); @Override long estimateSize(); @Override int characteristics(); @Override Comparator<? super T> getComparator();  }
@Test void testForEachRemaining() { printTestName(); final List<Integer> expected = Collections.singletonList(VALUE); final List<Integer> list = new ArrayList<>(); instance.forEachRemaining(list::add); assertEquals(expected, list); instance.forEachRemaining(list::add); assertEquals(expected, list); }