8019551: Make BaseStream public

Reviewed-by: chegar, psandoz
This commit is contained in:
Brian Goetz 2013-07-09 10:44:49 +02:00 committed by Paul Sandoz
parent 2409f0944c
commit 320200e8b7
2 changed files with 7 additions and 22 deletions

View File

@ -53,11 +53,6 @@ import java.util.function.Supplier;
* operation, the stream is considered to be consumed, and no more intermediate * operation, the stream is considered to be consumed, and no more intermediate
* or terminal operations are permitted on this stream instance. * or terminal operations are permitted on this stream instance.
* *
* <p>{@code AbstractPipeline} implements a number of methods that are
* specified in {@link BaseStream}, though it does not implement
* {@code BaseStream} directly. Subclasses of {@code AbstractPipeline}
* will generally implement {@code BaseStream}.
*
* @implNote * @implNote
* <p>For sequential streams, and parallel streams without * <p>For sequential streams, and parallel streams without
* <a href="package-summary.html#StreamOps">stateful intermediate * <a href="package-summary.html#StreamOps">stateful intermediate
@ -75,7 +70,7 @@ import java.util.function.Supplier;
* @since 1.8 * @since 1.8
*/ */
abstract class AbstractPipeline<E_IN, E_OUT, S extends BaseStream<E_OUT, S>> abstract class AbstractPipeline<E_IN, E_OUT, S extends BaseStream<E_OUT, S>>
extends PipelineHelper<E_OUT> { extends PipelineHelper<E_OUT> implements BaseStream<E_OUT, S> {
/** /**
* Backlink to the head of the pipeline chain (self if this is the source * Backlink to the head of the pipeline chain (self if this is the source
* stage). * stage).
@ -286,26 +281,20 @@ abstract class AbstractPipeline<E_IN, E_OUT, S extends BaseStream<E_OUT, S>>
// BaseStream // BaseStream
/** @Override
* Implements {@link BaseStream#sequential()}
*/
public final S sequential() { public final S sequential() {
sourceStage.parallel = false; sourceStage.parallel = false;
return (S) this; return (S) this;
} }
/** @Override
* Implements {@link BaseStream#parallel()}
*/
public final S parallel() { public final S parallel() {
sourceStage.parallel = true; sourceStage.parallel = true;
return (S) this; return (S) this;
} }
// Primitive specialization use co-variant overrides, hence is not final // Primitive specialization use co-variant overrides, hence is not final
/** @Override
* Implements {@link BaseStream#spliterator()}
*/
public Spliterator<E_OUT> spliterator() { public Spliterator<E_OUT> spliterator() {
if (linkedOrConsumed) if (linkedOrConsumed)
throw new IllegalStateException("stream has already been operated upon"); throw new IllegalStateException("stream has already been operated upon");
@ -331,9 +320,7 @@ abstract class AbstractPipeline<E_IN, E_OUT, S extends BaseStream<E_OUT, S>>
} }
} }
/** @Override
* Implements {@link BaseStream#isParallel()}
*/
public final boolean isParallel() { public final boolean isParallel() {
return sourceStage.parallel; return sourceStage.parallel;
} }

View File

@ -29,15 +29,13 @@ import java.util.Spliterator;
/** /**
* Base interface for stream types such as {@link Stream}, {@link IntStream}, * Base interface for stream types such as {@link Stream}, {@link IntStream},
* etc. Contains methods common to all stream types. Many of these methods * etc. Contains methods common to all stream types.
* are implemented by {@link AbstractPipeline}, even though
* {@code AbstractPipeline} does not directly implement {@code BaseStream}.
* *
* @param <T> type of stream elements * @param <T> type of stream elements
* @param <S> type of stream implementing {@code BaseStream} * @param <S> type of stream implementing {@code BaseStream}
* @since 1.8 * @since 1.8
*/ */
interface BaseStream<T, S extends BaseStream<T, S>> { public interface BaseStream<T, S extends BaseStream<T, S>> {
/** /**
* Returns an iterator for the elements of this stream. * Returns an iterator for the elements of this stream.
* *