changeset 8415:349f916c4c27

javadocs cleanups and extend generics so that ? super T is allowed for downstream Collector
author mduigou
date Fri, 26 Apr 2013 15:46:57 -0700
parents 06fa93a0a027
children d5456784b348
files src/share/classes/java/util/stream/Collectors.java
diffstat 1 files changed, 215 insertions(+), 177 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/util/stream/Collectors.java	Fri Apr 26 14:03:50 2013 -0700
+++ b/src/share/classes/java/util/stream/Collectors.java	Fri Apr 26 15:46:57 2013 -0700
@@ -63,7 +63,7 @@
  * <p>The following are examples of using the predefined {@code Collector}
  * implementations in {@link Collectors} with the {@code Stream} API to perform
  * mutable reduction tasks:
- * 
+ *
  * <pre>{@code
  *     // Accumulate elements into a List
  *     List<Person> list = people.collect(Collectors.toList());
@@ -106,7 +106,7 @@
 
     private static final Set<Collector.Characteristics> CH_CONCURRENT
             = Collections.unmodifiableSet(EnumSet.of(Collector.Characteristics.CONCURRENT,
-                                                     Collector.Characteristics.STRICTLY_MUTATIVE, 
+                                                     Collector.Characteristics.STRICTLY_MUTATIVE,
                                                      Collector.Characteristics.UNORDERED));
     private static final Set<Collector.Characteristics> CH_STRICT
             = Collections.unmodifiableSet(EnumSet.of(Collector.Characteristics.STRICTLY_MUTATIVE));
@@ -119,12 +119,13 @@
     /**
      * Returns a merge function, suitable for use in
      * {@link Map#merge(Object, Object, BiFunction) Map.merge()} or
-     * {@link #toMap(Function, Function, BinaryOperator) toMap()}, which always 
+     * {@link #toMap(Function, Function, BinaryOperator) toMap()}, which always
      * throws {@code IllegalStateException}.  This can be used to enforce the
      * assumption that the elements being collected are distinct.
      *
-     * @param <T> The type of input arguments to the merge function
-     * @return A merge function which always throw {@code IllegalStateException}
+     * @param <T> the type of input arguments to the merge function
+     * @return a merge function which always throw {@code IllegalStateException}
+     *
      * @see #firstWinsMerger()
      * @see #lastWinsMerger()
      */
@@ -135,11 +136,11 @@
     /**
      * Returns a merge function, suitable for use in
      * {@link Map#merge(Object, Object, BiFunction) Map.merge()} or
-     * {@link #toMap(Function, Function, BinaryOperator) toMap()}, 
+     * {@link #toMap(Function, Function, BinaryOperator) toMap()},
      * which implements a "first wins" policy.
      *
-     * @param <T> The type of input arguments to the merge function
-     * @return A merge function which always returns its first argument
+     * @param <T> the type of input arguments to the merge function
+     * @return a merge function which always returns its first argument
      * @see #lastWinsMerger()
      * @see #throwingMerger()
      */
@@ -150,11 +151,11 @@
     /**
      * Returns a merge function, suitable for use in
      * {@link Map#merge(Object, Object, BiFunction) Map.merge()} or
-     * {@link #toMap(Function, Function, BinaryOperator) toMap()}, 
+     * {@link #toMap(Function, Function, BinaryOperator) toMap()},
      * which implements a "last wins" policy.
      *
-     * @param <T> The type of input arguments to the merge function
-     * @return A merge function which always returns its second argument
+     * @param <T> the type of input arguments to the merge function
+     * @return a merge function which always returns its second argument
      * @see #firstWinsMerger()
      * @see #throwingMerger()
      */
@@ -162,7 +163,12 @@
         return (u,v) -> v;
     }
 
-    /** Simple implementation class for {@code Collector}. */
+    /**
+     * Simple implementation class for {@code Collector}.
+     *
+     * @param <T> the type of elements to be collected
+     * @param <R> the type of the result
+     */
     private static final class CollectorImpl<T, R> implements Collector<T,R> {
         private final Supplier<R> resultSupplier;
         private final BiFunction<R, T, R> accumulator;
@@ -211,11 +217,11 @@
      * new {@code Collection}, in encounter order.  The {@code Collection} is
      * created by the provided factory.
      *
-     * @param <T> The type of the input elements
-     * @param <C> The type of the resulting {@code Collection}
-     * @param collectionFactory A {@code Supplier} which returns a new, empty
+     * @param <T> the type of the input elements
+     * @param <C> the type of the resulting {@code Collection}
+     * @param collectionFactory a {@code Supplier} which returns a new, empty
      * {@code Collection} of the appropriate type
-     * @return A {@code Collector} which collects all the input elements into a
+     * @return a {@code Collector} which collects all the input elements into a
      * {@code Collection}, in encounter order
      */
     public static <T, C extends Collection<T>>
@@ -231,8 +237,8 @@
      * new {@code List}. There are no guarantees on the type, mutability,
      * serializability, or thread-safety of the {@code List} returned.
      *
-     * @param <T> The type of the input elements
-     * @return A {@code Collector} which collects all the input elements into a
+     * @param <T> the type of the input elements
+     * @return a {@code Collector} which collects all the input elements into a
      * {@code List}, in encounter order
      */
     public static <T>
@@ -276,8 +282,8 @@
      * <p>This is an {@link Collector.Characteristics#UNORDERED unordered}
      * Collector.
      *
-     * @param <T> The type of the input elements
-     * @return A {@code Collector} which collects all the input elements into a
+     * @param <T> the type of the input elements
+     * @return a {@code Collector} which collects all the input elements into a
      * {@code Set}
      */
     public static <T>
@@ -292,7 +298,7 @@
      * Returns a {@code Collector} that concatenates the input elements into a
      * new {@link StringBuilder}.
      *
-     * @return A {@code Collector} which collects String elements into a
+     * @return a {@code Collector} which collects String elements into a
      * {@code StringBuilder}, in encounter order
      */
     public static Collector<String, StringBuilder> toStringBuilder() {
@@ -306,9 +312,9 @@
      * Returns a {@code Collector} that concatenates the input elements into a
      * new {@link StringJoiner}, using the specified delimiter.
      *
+     * @param delimiter the delimiter to be used between each element
      * @return A {@code Collector} which collects String elements into a
      * {@code StringJoiner}, in encounter order
-     * @param delimiter the delimiter to be used between each element
      */
     public static Collector<CharSequence, StringJoiner> toStringJoiner(CharSequence delimiter) {
         BinaryOperator<StringJoiner> merger = (sj, other) -> {
@@ -325,12 +331,13 @@
      * {@code BinaryOperator<Map>} that merges the contents of its right
      * argument into its left argument, using the provided merge function to
      * handle duplicate keys.
-     * @param <K> Type of the map keys
-     * @param <V> Type of the map values
-     * @param <M> Type of the map
+     *
+     * @param <K> type of the map keys
+     * @param <V> type of the map values
+     * @param <M> type of the map
      * @param mergeFunction A merge function suitable for
      * {@link Map#merge(Object, Object, BiFunction) Map.merge()}
-     * @return A merge function for two maps
+     * @return a merge function for two maps
      */
     private static <K, V, M extends Map<K,V>>
     BinaryOperator<M> mapMerger(BinaryOperator<V> mergeFunction) {
@@ -356,17 +363,17 @@
      *                                              mapping(Person::getLastName, toSet())));
      * }</pre>
      *
-     * @param <T> The type of the input elements
-     * @param <U> Type of elements accepted by downstream collector
-     * @param <R> Result type of collector
-     * @param mapper A function to be applied to the input elements
-     * @param downstream A collector which will accept mapped values
-     * @return A collector which applies the mapping function to the input
+     * @param <T> the type of the input elements
+     * @param <U> type of elements accepted by downstream collector
+     * @param <R> result type of collector
+     * @param mapper a function to be applied to the input elements
+     * @param downstream a collector which will accept mapped values
+     * @return a collector which applies the mapping function to the input
      * elements and provides the mapped results to the downstream collector
      */
     public static <T, U, R> Collector<T, R>
-    mapping(Function<? super T, ? extends U> mapper, Collector<U, R> downstream) {
-        BiFunction<R, U, R> downstreamAccumulator = downstream.accumulator();
+    mapping(Function<? super T, ? extends U> mapper, Collector<? super U, R> downstream) {
+        BiFunction<R, ? super U, R> downstreamAccumulator = downstream.accumulator();
         return new CollectorImpl<>(downstream.resultSupplier(),
                                    (r, t) -> downstreamAccumulator.apply(r, mapper.apply(t)),
                                    downstream.combiner(), downstream.characteristics());
@@ -381,8 +388,9 @@
      * <pre>{@code
      *     reducing(0L, e -> 1L, Long::sum)
      * }</pre>
-     * @param <T> The type of the input elements
-     * @return A {@code Collector} that counts the input elements
+     *
+     * @param <T> the type of the input elements
+     * @return a {@code Collector} that counts the input elements
      */
     public static <T> Collector<T, Long>
     counting() {
@@ -398,9 +406,10 @@
      * <pre>{@code
      *     reducing(Comparators.lesserOf(comparator))
      * }</pre>
-     * @param <T> The type of the input elements
-     * @param comparator A {@code Comparator} for comparing elements
-     * @return A {@code Collector} that produces the minimal value
+     *
+     * @param <T> the type of the input elements
+     * @param comparator a {@code Comparator} for comparing elements
+     * @return a {@code Collector} that produces the minimal value
      */
     public static <T> Collector<T, T>
     minBy(Comparator<? super T> comparator) {
@@ -416,9 +425,10 @@
      * <pre>{@code
      *     reducing(Comparators.greaterOf(comparator))
      * }</pre>
-     * @param <T> The type of the input elements
-     * @param comparator A {@code Comparator} for comparing elements
-     * @return A {@code Collector} that produces the maximal value
+     *
+     * @param <T> the type of the input elements
+     * @param comparator a {@code Comparator} for comparing elements
+     * @return a {@code Collector} that produces the maximal value
      */
     public static <T> Collector<T, T>
     maxBy(Comparator<? super T> comparator) {
@@ -434,9 +444,10 @@
      * <pre>{@code
      *     reducing(0L, mapper, Long::sum)
      * }</pre>
-     * @param <T> The type of the input elements
-     * @param mapper A function extracting the property to be summed
-     * @return A {@code Collector} that produces the sum of a derived property
+     *
+     * @param <T> the type of the input elements
+     * @param mapper a function extracting the property to be summed
+     * @return a {@code Collector} that produces the sum of a derived property
      */
     public static <T> Collector<T, Long>
     sumBy(Function<? super T, Long> mapper) {
@@ -452,11 +463,13 @@
      * multi-level reduction, downstream of {@code groupingBy} or
      * {@code partitioningBy}.  To perform a simple reduction on a stream,
      * use {@link Stream#reduce(BinaryOperator)} instead.
-     * @param <T> Element type for the input and output of the reduction
-     * @param identity The identity value for the reduction (also, the value
+     *
+     * @param <T> element type for the input and output of the reduction
+     * @param identity the identity value for the reduction (also, the value
      *                 that is returned when there are no input elements)
-     * @param op A {@code BinaryOperator<T>} used to reduce the input elements
-     * @return A {@code Collector} which implements the reduction operation
+     * @param op a {@code BinaryOperator<T>} used to reduce the input elements
+     * @return a {@code Collector} which implements the reduction operation
+     *
      * @see #reducing(BinaryOperator)
      * @see #reducing(Object, Function, BinaryOperator)
      */
@@ -489,9 +502,11 @@
      * <pre>{@code
      *     reducing(null, op);
      * }</pre>
-     * @param <T> Element type for the input and output of the reduction
-     * @param op A {@code BinaryOperator<T>} used to reduce the input elements
-     * @return A {@code Collector} which implements the reduction operation
+     *
+     * @param <T> element type for the input and output of the reduction
+     * @param op a {@code BinaryOperator<T>} used to reduce the input elements
+     * @return a {@code Collector} which implements the reduction operation
+     *
      * @see #reducing(Object, BinaryOperator)
      * @see #reducing(Object, Function, BinaryOperator)
      */
@@ -523,13 +538,14 @@
      *                                              reducing(Person::getLastName, longerOf)));
      * }</pre>
      *
-     * @param <T> The type of the input elements
-     * @param <U> The type of the mapped values
-     * @param identity The identity value for the reduction (also, the value
+     * @param <T> the type of the input elements
+     * @param <U> the type of the mapped values
+     * @param identity the identity value for the reduction (also, the value
      *                 that is returned when there are no input elements)
-     * @param mapper A mapping function to apply to each input value
-     * @param op A {@code BinaryOperator<U>} used to reduce the mapped values
-     * @return A {@code Collector} implementing the map-reduce operation
+     * @param mapper a mapping function to apply to each input value
+     * @param op a {@code BinaryOperator<U>} used to reduce the mapped values
+     * @return a {@code Collector} implementing the map-reduce operation
+     *
      * @see #reducing(Object, BinaryOperator)
      * @see #reducing(BinaryOperator)
      */
@@ -562,10 +578,11 @@
      *     groupingBy(classifier, toList());
      * }</pre>
      *
-     * @param <T> The type of the input elements
-     * @param <K> The type of the keys
-     * @param classifier The classifier function mapping input elements to keys
-     * @return A {@code Collector} implementing the group-by operation
+     * @param <T> the type of the input elements
+     * @param <K> the type of the keys
+     * @param classifier the classifier function mapping input elements to keys
+     * @return a {@code Collector} implementing the group-by operation
+     *
      * @see #groupingBy(Function, Collector)
      * @see #groupingBy(Function, Supplier, Collector)
      * @see #groupingByConcurrent(Function)
@@ -597,19 +614,20 @@
      *                                              mapping(Person::getLastName, toSet())));
      * }</pre>
      *
-     * @param <T> The type of the input elements
-     * @param <K> The type of the keys
-     * @param <D> The result type of the downstream reduction
-     * @param classifier The classifier function mapping input elements to keys
-     * @param downstream A {@code Collector} implementing the downstream reduction
-     * @return A {@code Collector} implementing the cascaded group-by operation
+     * @param <T> the type of the input elements
+     * @param <K> the type of the keys
+     * @param <D> the result type of the downstream reduction
+     * @param classifier a classifier function mapping input elements to keys
+     * @param downstream a {@code Collector} implementing the downstream reduction
+     * @return a {@code Collector} implementing the cascaded group-by operation
      * @see #groupingBy(Function)
+     *
      * @see #groupingBy(Function, Supplier, Collector)
      * @see #groupingByConcurrent(Function, Collector)
      */
     public static <T, K, D>
     Collector<T, Map<K, D>> groupingBy(Function<? super T, ? extends K> classifier,
-                                       Collector<T, D> downstream) {
+                                       Collector<? super T, D> downstream) {
         return groupingBy(classifier, HashMap::new, downstream);
     }
 
@@ -634,15 +652,16 @@
      *                                              mapping(Person::getLastName, toSet())));
      * }</pre>
      *
-     * @param <T> The type of the input elements
-     * @param <K> The type of the keys
-     * @param <D> The result type of the downstream reduction
-     * @param <M> The type of the resulting {@code Map}
-     * @param classifier The classifier function mapping input elements to keys
-     * @param downstream A {@code Collector} implementing the downstream reduction
-     * @param mapFactory A function which, when called, produces a new empty
+     * @param <T> the type of the input elements
+     * @param <K> the type of the keys
+     * @param <D> the result type of the downstream reduction
+     * @param <M> the type of the resulting {@code Map}
+     * @param classifier a classifier function mapping input elements to keys
+     * @param downstream a {@code Collector} implementing the downstream reduction
+     * @param mapFactory a function which, when called, produces a new empty
      *                   {@code Map} of the desired type
-     * @return A {@code Collector} implementing the cascaded group-by operation
+     * @return a {@code Collector} implementing the cascaded group-by operation
+     *
      * @see #groupingBy(Function, Collector)
      * @see #groupingBy(Function)
      * @see #groupingByConcurrent(Function, Supplier, Collector)
@@ -650,9 +669,9 @@
     public static <T, K, D, M extends Map<K, D>>
     Collector<T, M> groupingBy(Function<? super T, ? extends K> classifier,
                                Supplier<M> mapFactory,
-                               Collector<T, D> downstream) {
+                               Collector<? super T, D> downstream) {
         Supplier<D> downstreamSupplier = downstream.resultSupplier();
-        BiFunction<D, T, D> downstreamAccumulator = downstream.accumulator();
+        BiFunction<D, ? super T, D> downstreamAccumulator = downstream.accumulator();
         BiFunction<M, T, M> accumulator = (m, t) -> {
             K key = Objects.requireNonNull(classifier.apply(t), "element cannot be mapped to a null key");
             D oldContainer = m.computeIfAbsent(key, k -> downstreamSupplier.get());
@@ -688,10 +707,11 @@
      *     groupingByConcurrent(classifier, toList());
      * }</pre>
      *
-     * @param <T> The type of the input elements
-     * @param <K> The type of the keys
-     * @param classifier The classifier function mapping input elements to keys
-     * @return A {@code Collector} implementing the group-by operation
+     * @param <T> the type of the input elements
+     * @param <K> the type of the keys
+     * @param classifier a classifier function mapping input elements to keys
+     * @return a {@code Collector} implementing the group-by operation
+     *
      * @see #groupingBy(Function)
      * @see #groupingByConcurrent(Function, Collector)
      * @see #groupingByConcurrent(Function, Supplier, Collector)
@@ -724,19 +744,20 @@
      *                                                        mapping(Person::getLastName, toSet())));
      * }</pre>
      *
-     * @param <T> The type of the input elements
-     * @param <K> The type of the keys
-     * @param <D> The result type of the downstream reduction
-     * @param classifier The classifier function mapping input elements to keys
-     * @param downstream A {@code Collector} implementing the downstream reduction
-     * @return A {@code Collector} implementing the cascaded group-by operation
+     * @param <T> the type of the input elements
+     * @param <K> the type of the keys
+     * @param <D> the result type of the downstream reduction
+     * @param classifier a classifier function mapping input elements to keys
+     * @param downstream a {@code Collector} implementing the downstream reduction
+     * @return a {@code Collector} implementing the cascaded group-by operation
+     *
      * @see #groupingBy(Function, Collector)
      * @see #groupingByConcurrent(Function)
      * @see #groupingByConcurrent(Function, Supplier, Collector)
      */
     public static <T, K, D>
     Collector<T, ConcurrentMap<K, D>> groupingByConcurrent(Function<? super T, ? extends K> classifier,
-                                                           Collector<T, D> downstream) {
+                                                           Collector<? super T, D> downstream) {
         return groupingByConcurrent(classifier, ConcurrentHashMap::new, downstream);
     }
 
@@ -765,15 +786,16 @@
      * }</pre>
      *
      *
-     * @param <T> The type of the input elements
-     * @param <K> The type of the keys
-     * @param <D> The result type of the downstream reduction
-     * @param <M> The type of the resulting {@code ConcurrentMap}
-     * @param classifier The classifier function mapping input elements to keys
-     * @param downstream A {@code Collector} implementing the downstream reduction
-     * @param mapFactory A function which, when called, produces a new empty
+     * @param <T> the type of the input elements
+     * @param <K> the type of the keys
+     * @param <D> the result type of the downstream reduction
+     * @param <M> the type of the resulting {@code ConcurrentMap}
+     * @param classifier a classifier function mapping input elements to keys
+     * @param downstream a {@code Collector} implementing the downstream reduction
+     * @param mapFactory a function which, when called, produces a new empty
      *                   {@code ConcurrentMap} of the desired type
-     * @return A {@code Collector} implementing the cascaded group-by operation
+     * @return a {@code Collector} implementing the cascaded group-by operation
+     *
      * @see #groupingByConcurrent(Function)
      * @see #groupingByConcurrent(Function, Collector)
      * @see #groupingBy(Function, Supplier, Collector)
@@ -781,9 +803,9 @@
     public static <T, K, D, M extends ConcurrentMap<K, D>>
     Collector<T, M> groupingByConcurrent(Function<? super T, ? extends K> classifier,
                                          Supplier<M> mapFactory,
-                                         Collector<T, D> downstream) {
+                                         Collector<? super T, D> downstream) {
         Supplier<D> downstreamSupplier = downstream.resultSupplier();
-        BiFunction<D, T, D> downstreamAccumulator = downstream.accumulator();
+        BiFunction<D, ? super T, D> downstreamAccumulator = downstream.accumulator();
         BinaryOperator<M> combiner = mapMerger(downstream.combiner());
         if (downstream.characteristics().contains(Collector.Characteristics.CONCURRENT)) {
             BiFunction<M, T, M> accumulator = (m, t) -> {
@@ -792,8 +814,7 @@
                 return m;
             };
             return new CollectorImpl<>(mapFactory, accumulator, combiner, CH_CONCURRENT);
-        }
-        else if (downstream.characteristics().contains(Collector.Characteristics.STRICTLY_MUTATIVE)) {
+        } else if (downstream.characteristics().contains(Collector.Characteristics.STRICTLY_MUTATIVE)) {
             BiFunction<M, T, M> accumulator = (m, t) -> {
                 K key = Objects.requireNonNull(classifier.apply(t), "element cannot be mapped to a null key");
                 D resultContainer = m.computeIfAbsent(key, k -> downstreamSupplier.get());
@@ -803,8 +824,7 @@
                 return m;
             };
             return new CollectorImpl<>(mapFactory, accumulator, combiner, CH_CONCURRENT);
-        }
-        else {
+        } else {
             BiFunction<M, T, M> accumulator = (m, t) -> {
                 K key = Objects.requireNonNull(classifier.apply(t), "element cannot be mapped to a null key");
                 do {
@@ -812,8 +832,7 @@
                     if (oldResult == null) {
                         if (m.putIfAbsent(key, downstreamAccumulator.apply(null, t)) == null)
                             return m;
-                    }
-                    else {
+                    } else {
                         synchronized (oldResult) {
                             if (m.get(key) != oldResult)
                                 continue;
@@ -837,9 +856,10 @@
      * There are no guarantees on the type, mutability,
      * serializability, or thread-safety of the {@code Map} returned.
      *
-     * @param <T> The type of the input elements
-     * @param predicate The predicate used for classifying input elements
-     * @return A {@code Collector} implementing the partitioning operation.
+     * @param <T> the type of the input elements
+     * @param predicate a predicate used for classifying input elements
+     * @return a {@code Collector} implementing the partitioning operation
+     *
      * @see #partitioningBy(Predicate, Collector)
      */
     public static <T>
@@ -854,28 +874,30 @@
      * {@code Map<Boolean, D>} whose values are the result of the downstream
      * reduction.
      *
-     * There are no guarantees on the type, mutability,
+     * <p>There are no guarantees on the type, mutability,
      * serializability, or thread-safety of the {@code Map} returned.
      *
-     * @param <T> The type of the input elements
-     * @param <D> The result type of the downstream reduction
-     * @param predicate The predicate used for classifying input elements
-     * @param downstream A {@code Collector} implementing the downstream reduction
-     * @return A {@code Collector} implementing the cascaded partitioning operation.
+     * @param <T> the type of the input elements
+     * @param <D> the result type of the downstream reduction
+     * @param predicate a predicate used for classifying input elements
+     * @param downstream a {@code Collector} implementing the downstream
+     *                   reduction
+     * @return a {@code Collector} implementing the cascaded partitioning
+     *         operation
+     *
      * @see #partitioningBy(Predicate)
      */
     public static <T, D>
     Collector<T, Map<Boolean, D>> partitioningBy(Predicate<? super T> predicate,
-                                                 Collector<T, D> downstream) {
-        BiFunction<D, T, D> downstreamAccumulator = downstream.accumulator();
+                                                 Collector<? super T, D> downstream) {
+        BiFunction<D, ? super T, D> downstreamAccumulator = downstream.accumulator();
         BiFunction<Map<Boolean, D>, T, Map<Boolean, D>> accumulator = (result, t) -> {
             Partition<D> asPartition = ((Partition<D>) result);
             if (predicate.test(t)) {
                 D newResult = downstreamAccumulator.apply(asPartition.forTrue, t);
                 if (newResult != asPartition.forTrue)
                     asPartition.forTrue = newResult;
-            }
-            else {
+            } else {
                 D newResult = downstreamAccumulator.apply(asPartition.forFalse, t);
                 if (newResult != asPartition.forFalse)
                     asPartition.forFalse = newResult;
@@ -887,7 +909,10 @@
                                    accumulator, partitionMerger(downstream.combiner()), CH_STRICT);
     }
 
-    /** Merge function for two partitions, given a merge function for the elements. */
+    /**
+     * Merge function for two partitions, given a merge function for the
+     * elements.
+     */
     private static <D> BinaryOperator<Map<Boolean, D>> partitionMerger(BinaryOperator<D> op) {
         return (m1, m2) -> {
             Partition<D> left = (Partition<D>) m1;
@@ -931,14 +956,16 @@
      *         students.stream().collect(toMap(Student::getId,
      *                                         Functions.identity());
      * }</pre>
-     * @param <T> The type of the input elements
-     * @param <K> The output type of the key mapping function
-     * @param <U> The output type of the value mapping function
-     * @param keyMapper The mapping function to produce keys
-     * @param valueMapper The mapping function to produce values
-     * @return A {@code Collector} which collects elements into a {@code Map}
+     *
+     * @param <T> the type of the input elements
+     * @param <K> the output type of the key mapping function
+     * @param <U> the output type of the value mapping function
+     * @param keyMapper a mapping function to produce keys
+     * @param valueMapper a mapping function to produce values
+     * @return a {@code Collector} which collects elements into a {@code Map}
      * whose keys and values are the result of applying mapping functions to
      * the input elements
+     *
      * @see #toMap(Function, Function, BinaryOperator)
      * @see #toMap(Function, Function, BinaryOperator, Supplier)
      * @see #toConcurrentMap(Function, Function)
@@ -965,26 +992,28 @@
      * of {@code Person}, and you want to produce a "phone book" mapping name to
      * address, but it is possible that two persons have the same name, you can
      * do as follows to gracefully deals with these collisions, and produce a
-     * {@code Map} mapping names to a concatened list of addresses:
+     * {@code Map} mapping names to a concatenated list of addresses:
      * <pre>{@code
      *     Map<String, String> phoneBook
      *         people.stream().collect(toMap(Person::getName,
      *                                       Person::getAddress,
      *                                       (s, a) -> s + ", " + a));
      * }</pre>
-     * @param <T> The type of the input elements
-     * @param <K> The output type of the key mapping function
-     * @param <U> The output type of the value mapping function
-     * @param keyMapper The mapping function to produce keys
-     * @param valueMapper The mapping function to produce values
-     * @param mergeFunction A merge function, used to resolve collisions between
+     *
+     * @param <T> the type of the input elements
+     * @param <K> the output type of the key mapping function
+     * @param <U> the output type of the value mapping function
+     * @param keyMapper a mapping function to produce keys
+     * @param valueMapper a mapping function to produce values
+     * @param mergeFunction a merge function, used to resolve collisions between
      *                      values associated with the same key, as supplied
      *                      to {@link Map#merge(Object, Object, BiFunction)}
-     * @return A {@code Collector} which collects elements into a {@code Map}
+     * @return a {@code Collector} which collects elements into a {@code Map}
      * whose keys are the result of applying a key mapping function to the input
      * elements, and whose values are the result of applying a value mapping
      * function to all input elements equal to the key and combining them
      * using the merge function
+     *
      * @see #toMap(Function, Function)
      * @see #toMap(Function, Function, BinaryOperator, Supplier)
      * @see #toConcurrentMap(Function, Function, BinaryOperator)
@@ -1004,22 +1033,23 @@
      * results are merged using the provided merging function.  The {@code Map}
      * is created by a provided supplier function.
      *
-     * @param <T> The type of the input elements
-     * @param <K> The output type of the key mapping function
-     * @param <U> The output type of the value mapping function
-     * @param <M> The type of the resulting {@code Map}
-     * @param keyMapper The mapping function to produce keys
-     * @param valueMapper The mapping function to produce values
-     * @param mergeFunction A merge function, used to resolve collisions between
+     * @param <T> the type of the input elements
+     * @param <K> the output type of the key mapping function
+     * @param <U> the output type of the value mapping function
+     * @param <M> the type of the resulting {@code Map}
+     * @param keyMapper a mapping function to produce keys
+     * @param valueMapper a mapping function to produce values
+     * @param mergeFunction a merge function, used to resolve collisions between
      *                      values associated with the same key, as supplied
      *                      to {@link Map#merge(Object, Object, BiFunction)}
-     * @param mapSupplier A function which returns a new, empty {@code Map} into
+     * @param mapSupplier a function which returns a new, empty {@code Map} into
      *                    which the results will be inserted
-     * @return A {@code Collector} which collects elements into a {@code Map}
+     * @return a {@code Collector} which collects elements into a {@code Map}
      * whose keys are the result of applying a key mapping function to the input
      * elements, and whose values are the result of applying a value mapping
      * function to all input elements equal to the key and combining them
      * using the merge function
+     *
      * @see #toMap(Function, Function)
      * @see #toMap(Function, Function, BinaryOperator)
      * @see #toConcurrentMap(Function, Function, BinaryOperator, Supplier)
@@ -1068,15 +1098,16 @@
      * <p>This is a {@link Collector.Characteristics#CONCURRENT concurrent} and
      * {@link Collector.Characteristics#UNORDERED unordered} Collector.
      *
-     * @param <T> The type of the input elements
-     * @param <K> The output type of the key mapping function
-     * @param <U> The output type of the value mapping function
-     * @param keyMapper The mapping function to produce keys
-     * @param valueMapper The mapping function to produce values
-     * @return A concurrent {@code Collector} which collects elements into a
+     * @param <T> the type of the input elements
+     * @param <K> the output type of the key mapping function
+     * @param <U> the output type of the value mapping function
+     * @param keyMapper the mapping function to produce keys
+     * @param valueMapper the mapping function to produce values
+     * @return a concurrent {@code Collector} which collects elements into a
      * {@code ConcurrentMap} whose keys are the result of applying a key mapping
      * function to the input elements, and whose values are the result of
      * applying a value mapping function to the input elements
+     *
      * @see #toMap(Function, Function)
      * @see #toConcurrentMap(Function, Function, BinaryOperator)
      * @see #toConcurrentMap(Function, Function, BinaryOperator, Supplier)
@@ -1103,7 +1134,7 @@
      * of {@code Person}, and you want to produce a "phone book" mapping name to
      * address, but it is possible that two persons have the same name, you can
      * do as follows to gracefully deals with these collisions, and produce a
-     * {@code Map} mapping names to a concatened list of addresses:
+     * {@code Map} mapping names to a concatenated list of addresses:
      * <pre>{@code
      *     Map<String, String> phoneBook
      *         people.stream().collect(toConcurrentMap(Person::getName,
@@ -1114,19 +1145,20 @@
      * <p>This is a {@link Collector.Characteristics#CONCURRENT concurrent} and
      * {@link Collector.Characteristics#UNORDERED unordered} Collector.
      *
-     * @param <T> The type of the input elements
-     * @param <K> The output type of the key mapping function
-     * @param <U> The output type of the value mapping function
-     * @param keyMapper The mapping function to produce keys
-     * @param valueMapper The mapping function to produce values
-     * @param mergeFunction A merge function, used to resolve collisions between
+     * @param <T> the type of the input elements
+     * @param <K> the output type of the key mapping function
+     * @param <U> the output type of the value mapping function
+     * @param keyMapper a mapping function to produce keys
+     * @param valueMapper a mapping function to produce values
+     * @param mergeFunction a merge function, used to resolve collisions between
      *                      values associated with the same key, as supplied
      *                      to {@link Map#merge(Object, Object, BiFunction)}
-     * @return A concurrent {@code Collector} which collects elements into a
+     * @return a concurrent {@code Collector} which collects elements into a
      * {@code ConcurrentMap} whose keys are the result of applying a key mapping
      * function to the input elements, and whose values are the result of
      * applying a value mapping function to all input elements equal to the key
      * and combining them using the merge function
+     *
      * @see #toConcurrentMap(Function, Function)
      * @see #toConcurrentMap(Function, Function, BinaryOperator, Supplier)
      * @see #toMap(Function, Function, BinaryOperator)
@@ -1146,25 +1178,26 @@
      * results are merged using the provided merging function.  The
      * {@code ConcurrentMap} is created by a provided supplier function.
      *
-     * <p>This is a {@link Collector.Characteristics#CONCURRENT concurrent} and 
+     * <p>This is a {@link Collector.Characteristics#CONCURRENT concurrent} and
      * {@link Collector.Characteristics#UNORDERED unordered} Collector.
      *
-     * @param <T> The type of the input elements
-     * @param <K> The output type of the key mapping function
-     * @param <U> The output type of the value mapping function
-     * @param <M> The type of the resulting {@code ConcurrentMap}
-     * @param keyMapper The mapping function to produce keys
-     * @param valueMapper The mapping function to produce values
-     * @param mergeFunction A merge function, used to resolve collisions between
+     * @param <T> the type of the input elements
+     * @param <K> the output type of the key mapping function
+     * @param <U> the output type of the value mapping function
+     * @param <M> the type of the resulting {@code ConcurrentMap}
+     * @param keyMapper a mapping function to produce keys
+     * @param valueMapper a mapping function to produce values
+     * @param mergeFunction a merge function, used to resolve collisions between
      *                      values associated with the same key, as supplied
      *                      to {@link Map#merge(Object, Object, BiFunction)}
-     * @param mapSupplier A function which returns a new, empty {@code Map} into
+     * @param mapSupplier a function which returns a new, empty {@code Map} into
      *                    which the results will be inserted
-     * @return A concurrent {@code Collector} which collects elements into a
+     * @return a concurrent {@code Collector} which collects elements into a
      * {@code ConcurrentMap} whose keys are the result of applying a key mapping
      * function to the input elements, and whose values are the result of
      * applying a value mapping function to all input elements equal to the key
      * and combining them using the merge function
+     *
      * @see #toConcurrentMap(Function, Function)
      * @see #toConcurrentMap(Function, Function, BinaryOperator)
      * @see #toMap(Function, Function, BinaryOperator, Supplier)
@@ -1186,9 +1219,10 @@
      * mapping function to each input element, and returns summary statistics
      * for the resulting values.
      *
-     * @param <T> The type of the input elements
-     * @param mapper The mapping function to apply to each element
-     * @return A {@code Collector} implementing the summary-statistics reduction
+     * @param <T> the type of the input elements
+     * @param mapper a mapping function to apply to each element
+     * @return a {@code Collector} implementing the summary-statistics reduction
+     *
      * @see #toDoubleSummaryStatistics(ToDoubleFunction)
      * @see #toLongSummaryStatistics(ToLongFunction)
      */
@@ -1204,9 +1238,10 @@
      * mapping function to each input element, and returns summary statistics
      * for the resulting values.
      *
-     * @param <T> The type of the input elements
-     * @param mapper The mapping function to apply to each element
-     * @return A {@code Collector} implementing the summary-statistics reduction
+     * @param <T> the type of the input elements
+     * @param mapper the mapping function to apply to each element
+     * @return a {@code Collector} implementing the summary-statistics reduction
+     *
      * @see #toDoubleSummaryStatistics(ToDoubleFunction)
      * @see #toIntSummaryStatistics(ToIntFunction)
      */
@@ -1222,9 +1257,10 @@
      * mapping function to each input element, and returns summary statistics
      * for the resulting values.
      *
-     * @param <T> The type of the input elements
-     * @param mapper The mapping function to apply to each element
-     * @return A {@code Collector} implementing the summary-statistics reduction
+     * @param <T> the type of the input elements
+     * @param mapper a mapping function to apply to each element
+     * @return a {@code Collector} implementing the summary-statistics reduction
+     *
      * @see #toLongSummaryStatistics(ToLongFunction)
      * @see #toIntSummaryStatistics(ToIntFunction)
      */
@@ -1235,7 +1271,9 @@
                                    (l, r) -> { l.combine(r); return l; }, CH_STRICT);
     }
 
-    /** Implementation class used by partitioningBy. */
+    /**
+     * Implementation class used by partitioningBy.
+     */
     private static final class Partition<T>
             extends AbstractMap<Boolean, T>
             implements Map<Boolean, T> {