src/java.base/share/classes/java/util/stream/Collectors.java

Print this page

        

*** 988,998 **** * elements, and whose corresponding values are {@code List}s containing the * input elements which map to the associated key under the classification * function. * * <p>There are no guarantees on the type, mutability, or serializability ! * of the {@code Map} or {@code List} objects returned, or of the * thread-safety of the {@code List} objects returned. * @implSpec * This produces a result similar to: * <pre>{@code * groupingByConcurrent(classifier, toList()); --- 988,998 ---- * elements, and whose corresponding values are {@code List}s containing the * input elements which map to the associated key under the classification * function. * * <p>There are no guarantees on the type, mutability, or serializability ! * of the {@code ConcurrentMap} or {@code List} objects returned, or of the * thread-safety of the {@code List} objects returned. * @implSpec * This produces a result similar to: * <pre>{@code * groupingByConcurrent(classifier, toList());
*** 1026,1035 **** --- 1026,1038 ---- * <p>The classification function maps elements to some key type {@code K}. * The downstream collector operates on elements of type {@code T} and * produces a result of type {@code D}. The resulting collector produces a * {@code Map<K, D>}. * + * <p>There are no guarantees on the type, mutability, or serializability + * of the {@code ConcurrentMap} returned. + * * <p>For example, to compute the set of last names of people in each city, * where the city names are sorted: * <pre>{@code * ConcurrentMap<City, Set<String>> namesByCity * = people.stream().collect(groupingByConcurrent(Person::getCity,
*** 1141,1151 **** * Returns a {@code Collector} which partitions the input elements according * to a {@code Predicate}, and organizes them into a * {@code Map<Boolean, List<T>>}. * * 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 a predicate used for classifying input elements * @return a {@code Collector} implementing the partitioning operation * --- 1144,1155 ---- * Returns a {@code Collector} which partitions the input elements according * to a {@code Predicate}, and organizes them into a * {@code Map<Boolean, List<T>>}. * * There are no guarantees on the type, mutability, ! * serializability, or thread-safety of the {@code Map} or {@code List} ! * returned. * * @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 *
*** 1210,1219 **** --- 1214,1226 ---- * {@link Object#equals(Object)}), an {@code IllegalStateException} is * thrown when the collection operation is performed. If the mapped keys * may have duplicates, use {@link #toMap(Function, Function, BinaryOperator)} * instead. * + * <p>There are no guarantees on the type, mutability, serializability, + * or thread-safety of the {@code Map} returned. + * * @apiNote * It is common for either the key or the value to be the input elements. * In this case, the utility method * {@link java.util.function.Function#identity()} may be helpful. * For example, the following produces a {@code Map} mapping
*** 1269,1278 **** --- 1276,1288 ---- * <p>If the mapped * keys contains duplicates (according to {@link Object#equals(Object)}), * the value mapping function is applied to each equal element, and the * results are merged using the provided merging function. * + * <p>There are no guarantees on the type, mutability, serializability, + * or thread-safety of the {@code Map} returned. + * * @apiNote * There are multiple ways to deal with collisions between multiple elements * mapping to the same key. The other forms of {@code toMap} simply use * a merge function that throws unconditionally, but you can easily write * more flexible merge policies. For example, if you have a stream
*** 1380,1389 **** --- 1390,1402 ---- * {@link Object#equals(Object)}), an {@code IllegalStateException} is * thrown when the collection operation is performed. If the mapped keys * may have duplicates, use * {@link #toConcurrentMap(Function, Function, BinaryOperator)} instead. * + * <p>There are no guarantees on the type, mutability, or serializability + * of the {@code ConcurrentMap} returned. + * * @apiNote * It is common for either the key or the value to be the input elements. * In this case, the utility method * {@link java.util.function.Function#identity()} may be helpful. * For example, the following produces a {@code Map} mapping
*** 1434,1443 **** --- 1447,1459 ---- * * <p>If the mapped keys contains duplicates (according to {@link Object#equals(Object)}), * the value mapping function is applied to each equal element, and the * results are merged using the provided merging function. * + * <p>There are no guarantees on the type, mutability, or serializability + * of the {@code ConcurrentMap} returned. + * * @apiNote * There are multiple ways to deal with collisions between multiple elements * mapping to the same key. The other forms of {@code toConcurrentMap} simply use * a merge function that throws unconditionally, but you can easily write * more flexible merge policies. For example, if you have a stream