changeset 7490:70bc1cf8584a

Javadoc for XxxPipeline
author briangoetz
date Wed, 20 Feb 2013 20:37:46 -0500
parents a66e0dfd2973
children 8875666d12a8
files src/share/classes/java/util/stream/DoublePipeline.java src/share/classes/java/util/stream/IntPipeline.java src/share/classes/java/util/stream/LongPipeline.java src/share/classes/java/util/stream/ReferencePipeline.java
diffstat 4 files changed, 97 insertions(+), 51 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/util/stream/DoublePipeline.java	Wed Feb 20 15:42:21 2013 -0800
+++ b/src/share/classes/java/util/stream/DoublePipeline.java	Wed Feb 20 20:37:46 2013 -0500
@@ -44,14 +44,28 @@
  */
 class DoublePipeline<E_IN> extends AbstractPipeline<E_IN, Double, DoubleStream> implements DoubleStream {
 
+    /**
+     * Constructor for the head of a stream pipeline.
+     *
+     * @param source {@code Spliterator} describing the stream source
+     * @param sourceFlags The source flags for the stream source, described in {@link StreamOpFlag}
+     */
     public DoublePipeline(Supplier<? extends Spliterator<Double>> source, int sourceFlags) {
         super((Supplier) source, sourceFlags);
     }
 
+    /**
+     * Constructor for appending an intermediate operation onto an existing pipeline.
+     *
+     * @param upstream the upstream element source.
+     * @param op the operation performed upon elements.
+     */
     public DoublePipeline(AbstractPipeline<?, E_IN, ?> upstream, IntermediateOp<E_IN, Double> op) {
         super(upstream, op);
     }
 
+    // Methods from AbstractPipeline
+
     @Override
     protected StreamShape getOutputShape() {
         return StreamShape.DOUBLE_VALUE;
@@ -105,8 +119,6 @@
         return Nodes.doubleMakeBuilder(exactSizeIfKnown);
     }
 
-    //
-
     @Override
     public Spliterator.OfDouble spliterator() {
         return adapt(super.spliterator());
@@ -123,7 +135,7 @@
         }
     }
 
-    //
+    // Stateless intermediate ops from DoubleStream
 
     @Override
     public DoubleStream map(DoubleUnaryOperator mapper) {
@@ -175,6 +187,21 @@
     }
 
     @Override
+    public DoubleStream peek(DoubleConsumer consumer) {
+        Objects.requireNonNull(consumer);
+        return chainedToDouble(0, StreamShape.DOUBLE_VALUE,
+                               (flags, sink) -> new Sink.ChainedDouble(sink) {
+                                   @Override
+                                   public void accept(double t) {
+                                       consumer.accept(t);
+                                       downstream.accept(t);
+                                   }
+                               });
+    }
+
+    // Stateful intermediate ops from DoubleStream
+
+    @Override
     public DoubleStream limit(long maxSize) {
         if (maxSize < 0)
             throw new IllegalArgumentException(Long.toString(maxSize));
@@ -199,23 +226,12 @@
     }
 
     @Override
-    public DoubleStream peek(DoubleConsumer consumer) {
-        Objects.requireNonNull(consumer);
-        return chainedToDouble(0, StreamShape.DOUBLE_VALUE,
-                               (flags, sink) -> new Sink.ChainedDouble(sink) {
-                                   @Override
-                                   public void accept(double t) {
-                                       consumer.accept(t);
-                                       downstream.accept(t);
-                                   }
-                               });
-    }
-
-    @Override
     public DoubleStream sorted() {
         return pipeline(new SortedOp.OfDouble());
     }
 
+    // Terminal ops from DoubleStream
+
     @Override
     public void forEach(DoubleConsumer consumer) {
         pipeline(ForEachOp.make(consumer));
--- a/src/share/classes/java/util/stream/IntPipeline.java	Wed Feb 20 15:42:21 2013 -0800
+++ b/src/share/classes/java/util/stream/IntPipeline.java	Wed Feb 20 20:37:46 2013 -0500
@@ -43,14 +43,28 @@
  */
 class IntPipeline<E_IN> extends AbstractPipeline<E_IN, Integer, IntStream> implements IntStream {
 
+    /**
+     * Constructor for the head of a stream pipeline.
+     *
+     * @param source {@code Spliterator} describing the stream source
+     * @param sourceFlags The source flags for the stream source, described in {@link StreamOpFlag}
+     */
     public IntPipeline(Supplier<? extends Spliterator<Integer>> source, int sourceFlags) {
         super((Supplier) source, sourceFlags);
     }
 
+    /**
+     * Constructor for appending an intermediate operation onto an existing pipeline.
+     *
+     * @param upstream the upstream element source.
+     * @param op the operation performed upon elements.
+     */
     public IntPipeline(AbstractPipeline<?, E_IN, ?> upstream, IntermediateOp<E_IN, Integer> op) {
         super(upstream, op);
     }
 
+    // Methods from AbstractPipeline
+
     @Override
     protected StreamShape getOutputShape() {
         return StreamShape.INT_VALUE;
@@ -104,8 +118,6 @@
         return Nodes.intMakeBuilder(exactSizeIfKnown);
     }
 
-    //
-
     @Override
     public Spliterator.OfInt spliterator() {
         return adapt(super.spliterator());
@@ -122,8 +134,7 @@
         }
     }
 
-    //
-
+    // Stateless intermediate ops from IntStream
 
     @Override
     public LongStream longs() {
@@ -197,6 +208,21 @@
     }
 
     @Override
+    public IntStream peek(IntConsumer consumer) {
+        Objects.requireNonNull(consumer);
+        return chainedToInt(0, StreamShape.INT_VALUE,
+                            (flags, sink) -> new Sink.ChainedInt(sink) {
+                                @Override
+                                public void accept(int t) {
+                                    consumer.accept(t);
+                                    downstream.accept(t);
+                                }
+                            });
+    }
+
+    // Stateful intermediate ops from IntStream
+
+    @Override
     public IntStream limit(long maxSize) {
         if (maxSize < 0)
             throw new IllegalArgumentException(Long.toString(maxSize));
@@ -221,23 +247,12 @@
     }
 
     @Override
-    public IntStream peek(IntConsumer consumer) {
-        Objects.requireNonNull(consumer);
-        return chainedToInt(0, StreamShape.INT_VALUE,
-                            (flags, sink) -> new Sink.ChainedInt(sink) {
-                                @Override
-                                public void accept(int t) {
-                                    consumer.accept(t);
-                                    downstream.accept(t);
-                                }
-                            });
-    }
-
-    @Override
     public IntStream sorted() {
         return pipeline(new SortedOp.OfInt());
     }
 
+    // Terminal ops from IntStream
+
     @Override
     public void forEach(IntConsumer consumer) {
         pipeline(ForEachOp.make(consumer));
--- a/src/share/classes/java/util/stream/LongPipeline.java	Wed Feb 20 15:42:21 2013 -0800
+++ b/src/share/classes/java/util/stream/LongPipeline.java	Wed Feb 20 20:37:46 2013 -0500
@@ -44,14 +44,28 @@
  */
 class LongPipeline<E_IN> extends AbstractPipeline<E_IN, Long, LongStream> implements LongStream {
 
+    /**
+     * Constructor for the head of a stream pipeline.
+     *
+     * @param source {@code Spliterator} describing the stream source
+     * @param sourceFlags The source flags for the stream source, described in {@link StreamOpFlag}
+     */
     public LongPipeline(Supplier<? extends Spliterator<Long>> source, int sourceFlags) {
         super((Supplier) source, sourceFlags);
     }
 
+    /**
+     * Constructor for appending an intermediate operation onto an existing pipeline.
+     *
+     * @param upstream the upstream element source.
+     * @param op the operation performed upon elements.
+     */
     public LongPipeline(AbstractPipeline<?, E_IN, ?> upstream, IntermediateOp<E_IN, Long> op) {
         super(upstream, op);
     }
 
+    // Methods from AbstractPipeline
+
     @Override
     protected StreamShape getOutputShape() {
         return StreamShape.LONG_VALUE;
@@ -105,8 +119,6 @@
         return Nodes.longMakeBuilder(exactSizeIfKnown);
     }
 
-    //
-
     @Override
     public Spliterator.OfLong spliterator() {
         return adapt(super.spliterator());
@@ -123,8 +135,7 @@
         }
     }
 
-    //
-
+    // Stateless intermediate ops from LongStream
 
     @Override
     public DoubleStream doubles() {
@@ -187,6 +198,21 @@
     }
 
     @Override
+    public LongStream peek(LongConsumer consumer) {
+        Objects.requireNonNull(consumer);
+        return chainedToLong(0, StreamShape.LONG_VALUE,
+                             (flags, sink) -> new Sink.ChainedLong(sink) {
+                                 @Override
+                                 public void accept(long t) {
+                                     consumer.accept(t);
+                                     downstream.accept(t);
+                                 }
+                             });
+    }
+
+    // Stateful intermediate ops from LongStream
+
+    @Override
     public LongStream limit(long maxSize) {
         if (maxSize < 0)
             throw new IllegalArgumentException(Long.toString(maxSize));
@@ -211,23 +237,12 @@
     }
 
     @Override
-    public LongStream peek(LongConsumer consumer) {
-        Objects.requireNonNull(consumer);
-        return chainedToLong(0, StreamShape.LONG_VALUE,
-                             (flags, sink) -> new Sink.ChainedLong(sink) {
-                                 @Override
-                                 public void accept(long t) {
-                                     consumer.accept(t);
-                                     downstream.accept(t);
-                                 }
-                             });
-    }
-
-    @Override
     public LongStream sorted() {
         return pipeline(new SortedOp.OfLong());
     }
 
+    // Terminal ops from LongStream
+
     @Override
     public void forEach(LongConsumer consumer) {
         pipeline(ForEachOp.make(consumer));
--- a/src/share/classes/java/util/stream/ReferencePipeline.java	Wed Feb 20 15:42:21 2013 -0800
+++ b/src/share/classes/java/util/stream/ReferencePipeline.java	Wed Feb 20 20:37:46 2013 -0500
@@ -55,7 +55,7 @@
      * Constructor for the head of a stream pipeline.
      *
      * @param source {@code Spliterator} describing the stream source
-     * @param sourceFlags The source flags for the stream source, described in {@link StreamOpFlags}
+     * @param sourceFlags The source flags for the stream source, described in {@link StreamOpFlag}
      */
     public<S> ReferencePipeline(Supplier<? extends Spliterator<S>> source,
                                 int sourceFlags) {