changeset 8790:dc643a58768e

More renamings in Collector API
author briangoetz
date Tue, 18 Jun 2013 11:47:17 -0400
parents 569088178418
children 29731c47f379
files src/share/classes/java/util/stream/Collector.java src/share/classes/java/util/stream/Collectors.java src/share/classes/java/util/stream/ReferencePipeline.java
diffstat 3 files changed, 35 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/util/stream/Collector.java	Tue Jun 18 14:39:51 2013 +0200
+++ b/src/share/classes/java/util/stream/Collector.java	Tue Jun 18 11:47:17 2013 -0400
@@ -101,16 +101,16 @@
  * <ul>
  *     <li>The first argument passed to the accumulator function, both
  *     arguments passed to the combiner function, and the argument passed to the
- *     transformer function must be the result of a previous invocation of the
+ *     finisher function must be the result of a previous invocation of the
  *     result supplier, accumulator, or combiner functions.</li>
  *     <li>The implementation should not do anything with the result of any of
  *     the result supplier, accumulator, or combiner functions other than to
- *     pass them again to the accumulator, combiner, or transformer functions,
+ *     pass them again to the accumulator, combiner, or finisher functions,
  *     or return them to the caller of the reduction operation.</li>
- *     <li>If a result is passed to the combiner or transformer
+ *     <li>If a result is passed to the combiner or finisher
  *     function, and the same object is not returned from that function, it is
  *     never used again.</li>
- *     <li>Once a result is passed to the combiner or transformer function, it
+ *     <li>Once a result is passed to the combiner or finisher function, it
  *     is never passed to the accumulator function again.</li>
  *     <li>For non-concurrent collectors, any result returned from the result
  *     supplier, accumulator, or combiner functions must be serially
@@ -136,7 +136,7 @@
  *     R container = collector.supplier().get();
  *     for (T t : data)
  *         collector.accumulator().accept(container, t);
- *     return collector.transformer().apply(container);
+ *     return collector.finisher().apply(container);
  * }</pre>
  *
  * <p>However, the library is free to partition the input, perform the reduction
@@ -201,7 +201,7 @@
      * @return a function which transforms the intermediate result to the final
      * result
      */
-    Function<A, R> transformer();
+    Function<A, R> finisher();
 
     /**
      * Returns a {@code Set} of {@code Collector.Characteristics} indicating
@@ -235,10 +235,10 @@
         UNORDERED,
 
         /**
-         * Indicates that the transformer function is the identity function and
+         * Indicates that the finisher function is the identity function and
          * can be elided.  If set, it must be the case that an unchecked cast
          * from A to R will succeed.
          */
-        IDENTITY_TRANSFORM
+        IDENTITY_FINISH
     }
 }
--- a/src/share/classes/java/util/stream/Collectors.java	Tue Jun 18 14:39:51 2013 +0200
+++ b/src/share/classes/java/util/stream/Collectors.java	Tue Jun 18 11:47:17 2013 -0400
@@ -109,15 +109,15 @@
     private static final Set<Collector.Characteristics> CH_CONCURRENT_ID
             = Collections.unmodifiableSet(EnumSet.of(Collector.Characteristics.CONCURRENT,
                                                      Collector.Characteristics.UNORDERED,
-                                                     Collector.Characteristics.IDENTITY_TRANSFORM));
+                                                     Collector.Characteristics.IDENTITY_FINISH));
     private static final Set<Collector.Characteristics> CH_CONCURRENT_NOID
             = Collections.unmodifiableSet(EnumSet.of(Collector.Characteristics.CONCURRENT,
                                                      Collector.Characteristics.UNORDERED));
     private static final Set<Collector.Characteristics> CH_ID
-            = Collections.unmodifiableSet(EnumSet.of(Collector.Characteristics.IDENTITY_TRANSFORM));
+            = Collections.unmodifiableSet(EnumSet.of(Collector.Characteristics.IDENTITY_FINISH));
     private static final Set<Collector.Characteristics> CH_UNORDERED_ID
             = Collections.unmodifiableSet(EnumSet.of(Collector.Characteristics.UNORDERED,
-                                                     Collector.Characteristics.IDENTITY_TRANSFORM));
+                                                     Collector.Characteristics.IDENTITY_FINISH));
     private static final Set<Collector.Characteristics> CH_NOID = Collections.emptySet();
 
     private Collectors() { }
@@ -146,18 +146,18 @@
         private final Supplier<A> supplier;
         private final BiConsumer<A, T> accumulator;
         private final BinaryOperator<A> combiner;
-        private final Function<A, R> transformer;
+        private final Function<A, R> finisher;
         private final Set<Characteristics> characteristics;
 
         CollectorImpl(Supplier<A> supplier,
                       BiConsumer<A, T> accumulator,
                       BinaryOperator<A> combiner,
-                      Function<A,R> transformer,
+                      Function<A,R> finisher,
                       Set<Characteristics> characteristics) {
             this.supplier = supplier;
             this.accumulator = accumulator;
             this.combiner = combiner;
-            this.transformer = transformer;
+            this.finisher = finisher;
             this.characteristics = characteristics;
         }
 
@@ -184,8 +184,8 @@
         }
 
         @Override
-        public Function<A, R> transformer() {
-            return transformer;
+        public Function<A, R> finisher() {
+            return finisher;
         }
 
         @Override
@@ -348,7 +348,7 @@
         BiConsumer<A, ? super U> downstreamAccumulator = downstream.accumulator();
         return new CollectorImpl<>(downstream.supplier(),
                                    (r, t) -> downstreamAccumulator.accept(r, mapper.apply(t)),
-                                   downstream.combiner(), downstream.transformer(),
+                                   downstream.combiner(), downstream.finisher(),
                                    downstream.characteristics());
     }
 
@@ -772,19 +772,19 @@
         @SuppressWarnings("unchecked")
         Supplier<Map<K, A>> mangledFactory = (Supplier<Map<K, A>>) mapFactory;
 
-        if (downstream.characteristics().contains(Collector.Characteristics.IDENTITY_TRANSFORM)) {
+        if (downstream.characteristics().contains(Collector.Characteristics.IDENTITY_FINISH)) {
             return new CollectorImpl<>(mangledFactory, accumulator, merger, CH_ID);
         }
         else {
             @SuppressWarnings("unchecked")
-            Function<A, A> downstreamTransformer = (Function<A, A>) downstream.transformer();
-            Function<Map<K, A>, M> transformer = intermediate -> {
-                intermediate.replaceAll((k, v) -> downstreamTransformer.apply(v));
+            Function<A, A> downstreamFinisher = (Function<A, A>) downstream.finisher();
+            Function<Map<K, A>, M> finisher = intermediate -> {
+                intermediate.replaceAll((k, v) -> downstreamFinisher.apply(v));
                 @SuppressWarnings("unchecked")
                 M castResult = (M) intermediate;
                 return castResult;
             };
-            return new CollectorImpl<>(mangledFactory, accumulator, merger, transformer, CH_NOID);
+            return new CollectorImpl<>(mangledFactory, accumulator, merger, finisher, CH_NOID);
         }
     }
 
@@ -846,7 +846,7 @@
      * where the city names are sorted:
      * <pre>{@code
      *     ConcurrentMap<City, Set<String>> namesByCity
-     *         = people.stream().collect(groupingByConcurrent(Person::getCity, TreeMap::new,
+     *         = people.stream().collect(groupingByConcurrent(Person::getCity, ConcurrentSkipListMap::new,
      *                                                        mapping(Person::getLastName, toSet())));
      * }</pre>
      *
@@ -935,19 +935,19 @@
             };
         }
 
-        if (downstream.characteristics().contains(Collector.Characteristics.IDENTITY_TRANSFORM)) {
+        if (downstream.characteristics().contains(Collector.Characteristics.IDENTITY_FINISH)) {
             return new CollectorImpl<>(mangledFactory, accumulator, merger, CH_CONCURRENT_ID);
         }
         else {
             @SuppressWarnings("unchecked")
-            Function<A, A> downstreamTransformer = (Function<A, A>) downstream.transformer();
-            Function<ConcurrentMap<K, A>, M> transformer = intermediate -> {
-                intermediate.replaceAll((k, v) -> downstreamTransformer.apply(v));
+            Function<A, A> downstreamFinisher = (Function<A, A>) downstream.finisher();
+            Function<ConcurrentMap<K, A>, M> finisher = intermediate -> {
+                intermediate.replaceAll((k, v) -> downstreamFinisher.apply(v));
                 @SuppressWarnings("unchecked")
                 M castResult = (M) intermediate;
                 return castResult;
             };
-            return new CollectorImpl<>(mangledFactory, accumulator, merger, transformer, CH_CONCURRENT_NOID);
+            return new CollectorImpl<>(mangledFactory, accumulator, merger, finisher, CH_CONCURRENT_NOID);
         }
     }
 
@@ -1009,16 +1009,16 @@
         };
         Supplier<Map<Boolean, A>> supplier = () -> new Partition<>(downstream.supplier().get(),
                                                                    downstream.supplier().get());
-        if (downstream.characteristics().contains(Collector.Characteristics.IDENTITY_TRANSFORM)) {
+        if (downstream.characteristics().contains(Collector.Characteristics.IDENTITY_FINISH)) {
             return new CollectorImpl<>(supplier, accumulator, merger, CH_ID);
         }
         else {
-            Function<Map<Boolean, A>, Map<Boolean, D>> transformer = (Map<Boolean, A> par) -> {
+            Function<Map<Boolean, A>, Map<Boolean, D>> finisher = (Map<Boolean, A> par) -> {
                 Partition<A> asAPartition = (Partition<A>) par;
-                return new Partition<>(downstream.transformer().apply(asAPartition.forTrue),
-                                       downstream.transformer().apply(asAPartition.forFalse));
+                return new Partition<>(downstream.finisher().apply(asAPartition.forTrue),
+                                       downstream.finisher().apply(asAPartition.forFalse));
             };
-            return new CollectorImpl<>(supplier, accumulator, merger, transformer, CH_NOID);
+            return new CollectorImpl<>(supplier, accumulator, merger, finisher, CH_NOID);
         }
     }
 
--- a/src/share/classes/java/util/stream/ReferencePipeline.java	Tue Jun 18 14:39:51 2013 +0200
+++ b/src/share/classes/java/util/stream/ReferencePipeline.java	Tue Jun 18 11:47:17 2013 -0400
@@ -502,9 +502,9 @@
         else {
             container = evaluate(ReduceOps.makeRef(collector));
         }
-        return collector.characteristics().contains(Collector.Characteristics.IDENTITY_TRANSFORM)
+        return collector.characteristics().contains(Collector.Characteristics.IDENTITY_FINISH)
                ? (R) container
-               : collector.transformer().apply(container);
+               : collector.finisher().apply(container);
     }
 
     @Override