8015798: Rename IntStream.longs/doubles and LongStream.doubles to asXxxStream
authorpsandoz
Mon, 10 Jun 2013 12:20:34 +0200
changeset 18154 5ede18269905
parent 18153 644df1dfb3be
child 18155 889970e5b728
8015798: Rename IntStream.longs/doubles and LongStream.doubles to asXxxStream Reviewed-by: alanb
jdk/src/share/classes/java/util/stream/IntPipeline.java
jdk/src/share/classes/java/util/stream/IntStream.java
jdk/src/share/classes/java/util/stream/LongPipeline.java
jdk/src/share/classes/java/util/stream/LongStream.java
jdk/test/java/util/stream/boottest/java/util/stream/SpinedBufferTest.java
jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/DoublePrimitiveOpsTests.java
jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/ExplodeOpTest.java
jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/ForEachOpTest.java
jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/MapOpTest.java
jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/MatchOpTest.java
jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/MinMaxTest.java
jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/PrimitiveSumTest.java
jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/StreamBuilderTest.java
jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/StreamSpliteratorTest.java
--- a/jdk/src/share/classes/java/util/stream/IntPipeline.java	Mon Jun 10 11:52:32 2013 +0200
+++ b/jdk/src/share/classes/java/util/stream/IntPipeline.java	Mon Jun 10 12:20:34 2013 +0200
@@ -183,7 +183,7 @@
     // Stateless intermediate ops from IntStream
 
     @Override
-    public final LongStream longs() {
+    public final LongStream asLongStream() {
         return new LongPipeline.StatelessOp<Integer>(this, StreamShape.INT_VALUE,
                                                      StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
             @Override
@@ -199,7 +199,7 @@
     }
 
     @Override
-    public final DoubleStream doubles() {
+    public final DoubleStream asDoubleStream() {
         return new DoublePipeline.StatelessOp<Integer>(this, StreamShape.INT_VALUE,
                                                        StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
             @Override
@@ -424,7 +424,7 @@
 
     @Override
     public final long count() {
-        return longs().map(e -> 1L).sum();
+        return asLongStream().map(e -> 1L).sum();
     }
 
     @Override
--- a/jdk/src/share/classes/java/util/stream/IntStream.java	Mon Jun 10 11:52:32 2013 +0200
+++ b/jdk/src/share/classes/java/util/stream/IntStream.java	Mon Jun 10 12:20:34 2013 +0200
@@ -625,7 +625,7 @@
      * @return a {@code LongStream} consisting of the elements of this stream,
      * converted to {@code long}
      */
-    LongStream longs();
+    LongStream asLongStream();
 
     /**
      * Returns a {@code DoubleStream} consisting of the elements of this stream,
@@ -634,7 +634,7 @@
      * @return a {@code DoubleStream} consisting of the elements of this stream,
      * converted to {@code double}
      */
-    DoubleStream doubles();
+    DoubleStream asDoubleStream();
 
     /**
      * Returns a {@code Stream} consisting of the elements of this stream,
--- a/jdk/src/share/classes/java/util/stream/LongPipeline.java	Mon Jun 10 11:52:32 2013 +0200
+++ b/jdk/src/share/classes/java/util/stream/LongPipeline.java	Mon Jun 10 12:20:34 2013 +0200
@@ -180,7 +180,7 @@
     // Stateless intermediate ops from LongStream
 
     @Override
-    public final DoubleStream doubles() {
+    public final DoubleStream asDoubleStream() {
         return new DoublePipeline.StatelessOp<Long>(this, StreamShape.LONG_VALUE,
                                                     StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
             @Override
--- a/jdk/src/share/classes/java/util/stream/LongStream.java	Mon Jun 10 11:52:32 2013 +0200
+++ b/jdk/src/share/classes/java/util/stream/LongStream.java	Mon Jun 10 12:20:34 2013 +0200
@@ -625,7 +625,7 @@
      * @return a {@code DoubleStream} consisting of the elements of this stream,
      * converted to {@code double}
      */
-    DoubleStream doubles();
+    DoubleStream asDoubleStream();
 
     /**
      * Returns a {@code Stream} consisting of the elements of this stream,
--- a/jdk/test/java/util/stream/boottest/java/util/stream/SpinedBufferTest.java	Mon Jun 10 11:52:32 2013 +0200
+++ b/jdk/test/java/util/stream/boottest/java/util/stream/SpinedBufferTest.java	Mon Jun 10 12:20:34 2013 +0200
@@ -300,7 +300,7 @@
 
         for (int size : sizes) {
             // @@@ replace with double range when implemented
-            double[] array = LongStream.range(0, size).doubles().toArray();
+            double[] array = LongStream.range(0, size).asDoubleStream().toArray();
             SpinedBuffer.OfDouble sb = new SpinedBuffer.OfDouble();
             Arrays.stream(array).forEach(sb);
 
--- a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/DoublePrimitiveOpsTests.java	Mon Jun 10 11:52:32 2013 +0200
+++ b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/DoublePrimitiveOpsTests.java	Mon Jun 10 12:20:34 2013 +0200
@@ -44,12 +44,12 @@
 
     public void testToArray() {
         {
-            double[] array =  LongStream.range(1, 10).doubles().map(i -> i * 2).toArray();
+            double[] array =  LongStream.range(1, 10).asDoubleStream().map(i -> i * 2).toArray();
             assertEquals(array, new double[]{2, 4, 6, 8, 10, 12, 14, 16, 18});
         }
 
         {
-            double[] array =  LongStream.range(1, 10).parallel().doubles().map(i -> i * 2).toArray();
+            double[] array =  LongStream.range(1, 10).parallel().asDoubleStream().map(i -> i * 2).toArray();
             assertEquals(array, new double[]{2, 4, 6, 8, 10, 12, 14, 16, 18});
         }
     }
@@ -99,7 +99,7 @@
         }
 
         {
-            double[] actual = LongStream.range(1, 100).parallel().doubles().limit(9).toArray();
+            double[] actual = LongStream.range(1, 100).parallel().asDoubleStream().limit(9).toArray();
             Assert.assertTrue(Arrays.equals(expected, actual));
         }
     }
--- a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/ExplodeOpTest.java	Mon Jun 10 11:52:32 2013 +0200
+++ b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/ExplodeOpTest.java	Mon Jun 10 12:20:34 2013 +0200
@@ -110,7 +110,7 @@
         result = exerciseOps(data, s -> DoubleStream.empty());
         assertEquals(0, result.size());
 
-        exerciseOps(data, s -> s.flatMap(e -> IntStream.range(0, (int) e).doubles()));
-        exerciseOps(data, s -> s.flatMap(e -> IntStream.range(0, (int) e).limit(10).doubles()));
+        exerciseOps(data, s -> s.flatMap(e -> IntStream.range(0, (int) e).asDoubleStream()));
+        exerciseOps(data, s -> s.flatMap(e -> IntStream.range(0, (int) e).limit(10).asDoubleStream()));
     }
 }
--- a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/ForEachOpTest.java	Mon Jun 10 11:52:32 2013 +0200
+++ b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/ForEachOpTest.java	Mon Jun 10 12:20:34 2013 +0200
@@ -205,7 +205,7 @@
     public void testDoubleForEachOrdered() {
         List<Integer> input = countTo(10000);
         TestData.OfDouble data = TestData.Factory.ofDoubleSupplier("[1, 10000]",
-                                                                   () -> IntStream.range(1, 10001).doubles());
+                                                                   () -> IntStream.range(1, 10001).asDoubleStream());
 
         Function<DoubleStream, List<Integer>> terminalFunc = s -> {
             List<Integer> l = new ArrayList<>();
--- a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/MapOpTest.java	Mon Jun 10 11:52:32 2013 +0200
+++ b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/MapOpTest.java	Mon Jun 10 12:20:34 2013 +0200
@@ -24,16 +24,6 @@
 
 import org.testng.annotations.Test;
 
-import java.util.function.DoubleToIntFunction;
-import java.util.function.DoubleToLongFunction;
-import java.util.function.Function;
-import java.util.function.IntToDoubleFunction;
-import java.util.function.IntToLongFunction;
-import java.util.function.LongToDoubleFunction;
-import java.util.function.LongToIntFunction;
-import java.util.function.ToDoubleFunction;
-import java.util.function.ToIntFunction;
-import java.util.function.ToLongFunction;
 import java.util.stream.*;
 
 import static java.util.stream.LambdaTestHelpers.*;
@@ -98,8 +88,8 @@
         exerciseOps(data, s -> s.mapToObj(i -> i));
         exerciseOps(data, s -> s.map(i -> 0));
         exerciseOps(data, s -> s.map(i -> i * 2));
-        exerciseOps(data, s -> s.longs());
-        exerciseOps(data, s -> s.doubles());
+        exerciseOps(data, s -> s.asLongStream());
+        exerciseOps(data, s -> s.asDoubleStream());
         exerciseOps(data, s -> s.boxed());
         exerciseOps(data, s -> s.mapToObj(Integer::toString));
         exerciseOps(data, s -> s.mapToLong(i -> i));
@@ -113,7 +103,7 @@
         exerciseOps(data, s -> s.mapToObj(i -> i));
         exerciseOps(data, s -> s.map(i -> 0L));
         exerciseOps(data, s -> s.map(i -> i * 2L));
-        exerciseOps(data, s -> s.doubles());
+        exerciseOps(data, s -> s.asDoubleStream());
         exerciseOps(data, s -> s.boxed());
         exerciseOps(data, s -> s.mapToObj(e -> Long.toString(e)));
         exerciseOps(data, s -> s.mapToInt(i -> (int) i));
--- a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/MatchOpTest.java	Mon Jun 10 11:52:32 2013 +0200
+++ b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/MatchOpTest.java	Mon Jun 10 12:20:34 2013 +0200
@@ -318,17 +318,17 @@
     }
 
     public void testDoubleStreamMatches() {
-        assertDoublePredicates(() -> LongStream.range(0, 0).doubles(), Kind.ANY, DOUBLE_PREDICATES, false, false, false, false);
-        assertDoublePredicates(() -> LongStream.range(0, 0).doubles(), Kind.ALL, DOUBLE_PREDICATES, true, true, true, true);
-        assertDoublePredicates(() -> LongStream.range(0, 0).doubles(), Kind.NONE, DOUBLE_PREDICATES, true, true, true, true);
+        assertDoublePredicates(() -> LongStream.range(0, 0).asDoubleStream(), Kind.ANY, DOUBLE_PREDICATES, false, false, false, false);
+        assertDoublePredicates(() -> LongStream.range(0, 0).asDoubleStream(), Kind.ALL, DOUBLE_PREDICATES, true, true, true, true);
+        assertDoublePredicates(() -> LongStream.range(0, 0).asDoubleStream(), Kind.NONE, DOUBLE_PREDICATES, true, true, true, true);
 
-        assertDoublePredicates(() -> LongStream.range(1, 2).doubles(), Kind.ANY, DOUBLE_PREDICATES, true, false, false, true);
-        assertDoublePredicates(() -> LongStream.range(1, 2).doubles(), Kind.ALL, DOUBLE_PREDICATES, true, false, false, true);
-        assertDoublePredicates(() -> LongStream.range(1, 2).doubles(), Kind.NONE, DOUBLE_PREDICATES, false, true, true, false);
+        assertDoublePredicates(() -> LongStream.range(1, 2).asDoubleStream(), Kind.ANY, DOUBLE_PREDICATES, true, false, false, true);
+        assertDoublePredicates(() -> LongStream.range(1, 2).asDoubleStream(), Kind.ALL, DOUBLE_PREDICATES, true, false, false, true);
+        assertDoublePredicates(() -> LongStream.range(1, 2).asDoubleStream(), Kind.NONE, DOUBLE_PREDICATES, false, true, true, false);
 
-        assertDoublePredicates(() -> LongStream.range(1, 6).doubles(), Kind.ANY, DOUBLE_PREDICATES, true, false, true, true);
-        assertDoublePredicates(() -> LongStream.range(1, 6).doubles(), Kind.ALL, DOUBLE_PREDICATES, true, false, false, false);
-        assertDoublePredicates(() -> LongStream.range(1, 6).doubles(), Kind.NONE, DOUBLE_PREDICATES, false, true, false, false);
+        assertDoublePredicates(() -> LongStream.range(1, 6).asDoubleStream(), Kind.ANY, DOUBLE_PREDICATES, true, false, true, true);
+        assertDoublePredicates(() -> LongStream.range(1, 6).asDoubleStream(), Kind.ALL, DOUBLE_PREDICATES, true, false, false, false);
+        assertDoublePredicates(() -> LongStream.range(1, 6).asDoubleStream(), Kind.NONE, DOUBLE_PREDICATES, false, true, false, false);
     }
 
     @Test(dataProvider = "DoubleStreamTestData", dataProviderClass = DoubleStreamTestDataProvider.class)
--- a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/MinMaxTest.java	Mon Jun 10 11:52:32 2013 +0200
+++ b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/MinMaxTest.java	Mon Jun 10 12:20:34 2013 +0200
@@ -80,8 +80,8 @@
     public void testDoubleMinMax() {
         assertEquals(DoubleStream.empty().min(), OptionalDouble.empty());
         assertEquals(DoubleStream.empty().max(), OptionalDouble.empty());
-        assertEquals(1.0, LongStream.range(1, 1001).doubles().min().getAsDouble());
-        assertEquals(1000.0, LongStream.range(1, 1001).doubles().max().getAsDouble());
+        assertEquals(1.0, LongStream.range(1, 1001).asDoubleStream().min().getAsDouble());
+        assertEquals(1000.0, LongStream.range(1, 1001).asDoubleStream().max().getAsDouble());
     }
 
     @Test(dataProvider = "DoubleStreamTestData", dataProviderClass = DoubleStreamTestDataProvider.class)
--- a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/PrimitiveSumTest.java	Mon Jun 10 11:52:32 2013 +0200
+++ b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/PrimitiveSumTest.java	Mon Jun 10 12:20:34 2013 +0200
@@ -34,7 +34,7 @@
 
         withData(data).
                 terminal(s -> (long) s.sum()).
-                expectedResult(data.stream().longs().reduce(0, LambdaTestHelpers.lrPlus)).
+                expectedResult(data.stream().asLongStream().reduce(0, LambdaTestHelpers.lrPlus)).
                 exercise();
     }
 
--- a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/StreamBuilderTest.java	Mon Jun 10 11:52:32 2013 +0200
+++ b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/StreamBuilderTest.java	Mon Jun 10 12:20:34 2013 +0200
@@ -275,7 +275,7 @@
     @Test(dataProvider = "sizes")
     public void testDoubleAfterBuilding(int size) {
         StreamBuilder.OfDouble sb = DoubleStream.builder();
-        IntStream.range(0, size).doubles().forEach(sb);
+        IntStream.range(0, size).asDoubleStream().forEach(sb);
         sb.build();
 
         checkISE(() -> sb.accept(1));
@@ -287,13 +287,13 @@
     public void testDoubleStreamBuilder(int size) {
         testDoubleStreamBuilder(size, (s) -> {
             StreamBuilder.OfDouble sb = DoubleStream.builder();
-            IntStream.range(0, s).doubles().forEach(sb);
+            IntStream.range(0, s).asDoubleStream().forEach(sb);
             return sb.build();
         });
 
         testDoubleStreamBuilder(size, (s) -> {
             StreamBuilder.OfDouble sb = DoubleStream.builder();
-            IntStream.range(0, s).doubles().forEach(i -> {
+            IntStream.range(0, s).asDoubleStream().forEach(i -> {
                 StreamBuilder.OfDouble _sb = sb.add(i);
                 assertTrue(sb == _sb);
             });
@@ -307,12 +307,12 @@
 
         withData(data).
                 stream(s -> s).
-                expectedResult(IntStream.range(0, size).doubles().toArray()).
+                expectedResult(IntStream.range(0, size).asDoubleStream().toArray()).
                 exercise();
 
         withData(data).
                 stream(s -> s.map(i -> i)).
-                expectedResult(IntStream.range(0, size).doubles().toArray()).
+                expectedResult(IntStream.range(0, size).asDoubleStream().toArray()).
                 exercise();
     }
 
--- a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/StreamSpliteratorTest.java	Mon Jun 10 11:52:32 2013 +0200
+++ b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/StreamSpliteratorTest.java	Mon Jun 10 12:20:34 2013 +0200
@@ -526,7 +526,7 @@
                 for (boolean proxyEstimateSize : new boolean[]{false, true}) {
                     // Size is assumed to be larger than the target size for no splitting
                     // @@@ Need way to obtain the target size
-                    Spliterator.OfDouble sp = intermediateOp.apply(IntStream.range(0, 1000).doubles()).spliterator();
+                    Spliterator.OfDouble sp = intermediateOp.apply(IntStream.range(0, 1000).asDoubleStream()).spliterator();
                     ProxyNoExactSizeSpliterator.OfDouble psp = new ProxyNoExactSizeSpliterator.OfDouble(sp, proxyEstimateSize);
                     DoubleStream s = StreamSupport.doubleParallelStream(psp);
                     terminalOp.accept(s);