@Test public void generator1() { final Spliterator<Integer> spliterator = new GeneratorSpliterator<>( i -> { final int s = i == null ? 0 : i; return Stream.of(s + 1, s + 2, s + 3).spliterator(); } ); final int[] array = StreamSupport.stream(spliterator, false) .limit(10) .mapToInt(Integer::intValue) .toArray(); Assert.assertEquals(array, new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}); }
private Spliterator<T> spliterator() { if (_current == null) { _current = _generator.apply(_element); } return _current; }
GeneratorSpliterator implements Spliterator<T> { private Spliterator<T> spliterator() { if (_current == null) { _current = _generator.apply(_element); } return _current; } }
GeneratorSpliterator implements Spliterator<T> { private Spliterator<T> spliterator() { if (_current == null) { _current = _generator.apply(_element); } return _current; } GeneratorSpliterator(
		final Function<? super T, ? extends Spliterator<T>> generator
	); }
GeneratorSpliterator implements Spliterator<T> { private Spliterator<T> spliterator() { if (_current == null) { _current = _generator.apply(_element); } return _current; } GeneratorSpliterator(
		final Function<? super T, ? extends Spliterator<T>> generator
	); @Override boolean tryAdvance(final Consumer<? super T> action); @Override Spliterator<T> trySplit(); @Override long estimateSize(); @Override int characteristics(); }
GeneratorSpliterator implements Spliterator<T> { private Spliterator<T> spliterator() { if (_current == null) { _current = _generator.apply(_element); } return _current; } GeneratorSpliterator(
		final Function<? super T, ? extends Spliterator<T>> generator
	); @Override boolean tryAdvance(final Consumer<? super T> action); @Override Spliterator<T> trySplit(); @Override long estimateSize(); @Override int characteristics();  }