--- old/src/share/classes/java/util/DoubleSummaryStatistics.java 2013-07-05 16:26:12.098024206 -0700 +++ new/src/share/classes/java/util/DoubleSummaryStatistics.java 2013-07-05 16:26:08.310024273 -0700 @@ -45,14 +45,14 @@ * *
 {@code
  * DoubleSummaryStatistics stats = people.stream()
- *     .collect(Collectors.toDoubleSummaryStatistics(Person::getWeight));
+ *     .collect(Collectors.summarizingDouble(Person::getWeight));
  *}
* * This computes, in a single pass, the count of people, as well as the minimum, * maximum, sum, and average of their weights. * * @implNote This implementation is not thread safe. However, it is safe to use - * {@link java.util.stream.Collectors#toDoubleSummaryStatistics(java.util.function.ToDoubleFunction) + * {@link java.util.stream.Collectors#summarizingDouble(java.util.function.ToDoubleFunction) * Collectors.toDoubleStatistics()} on a parallel stream, because the parallel * implementation of {@link java.util.stream.Stream#collect Stream.collect()} * provides the necessary partitioning, isolation, and merging of results for --- old/src/share/classes/java/util/IntSummaryStatistics.java 2013-07-05 16:26:31.062023869 -0700 +++ new/src/share/classes/java/util/IntSummaryStatistics.java 2013-07-05 16:26:27.078023940 -0700 @@ -45,14 +45,14 @@ * *
 {@code
  * IntSummaryStatistics stats = people.stream()
- *     .collect(Collectors.toIntSummaryStatistics(Person::getDependents));
+ *     .collect(Collectors.summarizingInt(Person::getDependents));
  *}
* * This computes, in a single pass, the count of people, as well as the minimum, * maximum, sum, and average of their number of dependents. * * @implNote This implementation is not thread safe. However, it is safe to use - * {@link java.util.stream.Collectors#toIntSummaryStatistics(java.util.function.ToIntFunction) + * {@link java.util.stream.Collectors#summarizingInt(java.util.function.ToIntFunction) * Collectors.toIntStatistics()} on a parallel stream, because the parallel * implementation of {@link java.util.stream.Stream#collect Stream.collect()} * provides the necessary partitioning, isolation, and merging of results for --- old/src/share/classes/java/util/LongSummaryStatistics.java 2013-07-05 16:26:46.930023587 -0700 +++ new/src/share/classes/java/util/LongSummaryStatistics.java 2013-07-05 16:26:43.182023654 -0700 @@ -46,14 +46,14 @@ * *
 {@code
  * LongSummaryStatistics stats = people.stream()
- *     .collect(Collectors.toLongSummaryStatistics(Person::getAge));
+ *     .collect(Collectors.summarizingLong(Person::getAge));
  *}
* * This computes, in a single pass, the count of people, as well as the minimum, * maximum, sum, and average of their ages in milliseconds. * * @implNote This implementation is not thread safe. However, it is safe to use - * {@link java.util.stream.Collectors#toLongSummaryStatistics(java.util.function.ToLongFunction) + * {@link java.util.stream.Collectors#summarizingLong(java.util.function.ToLongFunction) * Collectors.toLongStatistics()} on a parallel stream, because the parallel * implementation of {@link java.util.stream.Stream#collect Stream.collect()} * provides the necessary partitioning, isolation, and merging of results for --- old/src/share/classes/java/util/StringJoiner.java 2013-07-05 16:27:02.450023311 -0700 +++ new/src/share/classes/java/util/StringJoiner.java 2013-07-05 16:26:58.818023376 -0700 @@ -49,16 +49,16 @@ *

* A {@code StringJoiner} may be employed to create formatted output from a * {@link java.util.stream.Stream} using - * {@link java.util.stream.Collectors#toStringJoiner}. For example: + * {@link java.util.stream.Collectors#joining}. For example: * *

 {@code
  * List numbers = Arrays.asList(1, 2, 3, 4);
  * String commaSeparatedNumbers = numbers.stream()
  *     .map(i -> i.toString())
- *     .collect(Collectors.toStringJoiner(", ")).toString();
+ *     .collect(Collectors.joining(", "));
  * }
* - * @see java.util.stream.Collectors#toStringJoiner + * @see java.util.stream.Collectors#joining * @since 1.8 */ public final class StringJoiner { --- old/src/share/classes/java/util/stream/Collector.java 2013-07-05 16:27:18.402023028 -0700 +++ new/src/share/classes/java/util/stream/Collector.java 2013-07-05 16:27:14.718023093 -0700 @@ -25,40 +25,45 @@ package java.util.stream; import java.util.Collections; +import java.util.EnumSet; import java.util.Set; -import java.util.function.BiFunction; +import java.util.function.BiConsumer; import java.util.function.BinaryOperator; +import java.util.function.Function; import java.util.function.Supplier; /** * A reduction operation that - * supports folding input elements into a cumulative result. The result may be - * a value or may be a mutable result container. Examples of operations - * accumulating results into a mutable result container include: accumulating - * input elements into a {@code Collection}; concatenating strings into a - * {@code StringBuilder}; computing summary information about elements such as - * sum, min, max, or average; computing "pivot table" summaries such as "maximum - * valued transaction by seller", etc. Reduction operations can be performed - * either sequentially or in parallel. + * folds input elements into a mutable result container, optionally transforming + * the accumulated result into a final representation after all input elements + * have been processed. + * + *

Examples of mutable reduction operations include: + * accumulating elements into a {@code Collection}; concatenating + * strings using a {@code StringBuilder}; computing summary information about + * elements such as sum, min, max, or average; computing "pivot table" summaries + * such as "maximum valued transaction by seller", etc. Reduction operations + * can be performed either sequentially or in parallel. * *

The following are examples of using the predefined {@code Collector} * implementations in {@link Collectors} with the {@code Stream} API to perform * mutable reduction tasks: *

{@code
- *     // Accumulate elements into a List
- *     List list = stream.collect(Collectors.toList());
+ *     // Accumulate names into a List
+ *     List list = people.stream().map(Person::getName).collect(Collectors.toList());
  *
- *     // Accumulate elements into a TreeSet
- *     Set list = stream.collect(Collectors.toCollection(TreeSet::new));
+ *     // Accumulate names into a TreeSet
+ *     Set list = people.stream().map(Person::getName).collect(Collectors.toCollection(TreeSet::new));
  *
  *     // Convert elements to strings and concatenate them, separated by commas
- *     String joined = stream.map(Object::toString)
- *                           .collect(Collectors.toStringJoiner(", "))
- *                           .toString();
+ *     String joined = things.stream()
+ *                           .map(Object::toString)
+ *                           .collect(Collectors.joining(", "));
  *
  *     // Find highest-paid employee
  *     Employee highestPaid = employees.stream()
- *                                     .collect(Collectors.maxBy(Comparators.comparing(Employee::getSalary)));
+ *                                     .collect(Collectors.maxBy(Comparators.comparing(Employee::getSalary)))
+ *                                     .get();
  *
  *     // Group employees by department
  *     Map> byDept
@@ -66,7 +71,7 @@
  *                    .collect(Collectors.groupingBy(Employee::getDepartment));
  *
  *     // Find highest-paid employee by department
- *     Map highestPaidByDept
+ *     Map> highestPaidByDept
  *         = employees.stream()
  *                    .collect(Collectors.groupingBy(Employee::getDepartment,
  *                                                   Collectors.maxBy(Comparators.comparing(Employee::getSalary))));
@@ -74,43 +79,42 @@
  *     // Partition students into passing and failing
  *     Map> passingFailing =
  *         students.stream()
- *                 .collect(Collectors.partitioningBy(s -> s.getGrade() >= PASS_THRESHOLD);
+ *                 .collect(Collectors.partitioningBy(s -> s.getGrade() >= PASS_THRESHOLD));
  *
  * }
* - *

A {@code Collector} is specified by three functions that work together to - * manage a result or result container. They are: creation of an initial - * result, incorporating a new data element into a result, and combining two - * results into one. The last function -- combining two results into one -- is - * used during parallel operations, where subsets of the input are accumulated - * in parallel, and then the subresults merged into a combined result. The - * result may be a mutable container or a value. If the result is mutable, the - * accumulation and combination functions may either mutate their left argument - * and return that (such as adding elements to a collection), or return a new - * result, in which case it should not perform any mutation. - * - *

Collectors also have a set of characteristics, including - * {@link Characteristics#CONCURRENT} and - * {@link Characteristics#STRICTLY_MUTATIVE}. These characteristics provide + *

A {@code Collector} is specified by four functions that work together to + * accumulate entries into a mutable result container, and optionally perform + * a final transform on the result. They are: creation of a new result container, + * incorporating a new data element into a result container, combining two + * result containers into one, and performing a final transform on the container. + * The combiner function is used during parallel operations, where + * subsets of the input are accumulated into separate result + * containers, and then the subresults merged into a combined result. The + * combiner function may merge one set of subresults into the other and return + * that, or it may return a new object to describe the combined results. + * + *

Collectors also have a set of characteristics, such as + * {@link Characteristics#CONCURRENT}. These characteristics provide * hints that can be used by a reduction implementation to provide better * performance. * *

Libraries that implement reduction based on {@code Collector}, such as * {@link Stream#collect(Collector)}, must adhere to the following constraints: *