提交 605a051c 编写于 作者: P psandoz

8019551: Make BaseStream public

Reviewed-by: chegar, psandoz
Contributed-by: Nbrian goetz <brian.goetz@oracle.com>
上级 a96e6090
...@@ -53,11 +53,6 @@ import java.util.function.Supplier; ...@@ -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; ...@@ -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>> ...@@ -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>> ...@@ -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;
} }
......
...@@ -29,15 +29,13 @@ import java.util.Spliterator; ...@@ -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.
* *
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册