8170943: Collectors.partitioningBy should specify that false and true entries are always present
Reviewed-by: psandoz
--- a/jdk/src/java.base/share/classes/java/util/stream/Collectors.java Tue Dec 13 17:40:53 2016 -0800
+++ b/jdk/src/java.base/share/classes/java/util/stream/Collectors.java Tue Dec 13 17:45:37 2016 -0800
@@ -1268,10 +1268,16 @@
* to a {@code Predicate}, and organizes them into a
* {@code Map<Boolean, List<T>>}.
*
+ * The returned {@code Map} always contains mappings for both
+ * {@code false} and {@code true} keys.
* There are no guarantees on the type, mutability,
* serializability, or thread-safety of the {@code Map} or {@code List}
* returned.
*
+ * @apiNote
+ * If a partition has no elements, its value in the result Map will be
+ * an empty List.
+ *
* @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
@@ -1290,9 +1296,17 @@
* {@code Map<Boolean, D>} whose values are the result of the downstream
* reduction.
*
- * <p>There are no guarantees on the type, mutability,
+ * <p>
+ * The returned {@code Map} always contains mappings for both
+ * {@code false} and {@code true} keys.
+ * There are no guarantees on the type, mutability,
* serializability, or thread-safety of the {@code Map} returned.
*
+ * @apiNote
+ * If a partition has no elements, its value in the result Map will be
+ * obtained by calling the downstream collector's supplier function and then
+ * applying the finisher function.
+ *
* @param <T> the type of the input elements
* @param <A> the intermediate accumulation type of the downstream collector
* @param <D> the result type of the downstream reduction