-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
8
FULL PRODUCT VERSION :
A DESCRIPTION OF THE PROBLEM :
The javadoc of java.util.stream.Collectors#toMap method starts by referencing the correct java.util.function.Function#identity() method but uses Functions.identity() in the code sample.
* @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
* students to their grade point average:
* <pre>{@code
* Map<Student, Double> studentToGPA
* students.stream().collect(toMap(Functions.identity(),
* student -> computeGPA(student)));
* }</pre>
* And the following produces a {@code Map} mapping a unique identifier to
* students:
* <pre>{@code
* Map<String, Student> studentIdToStudent
* students.stream().collect(toMap(Student::getId,
* Functions.identity());
* }</pre>
REPRODUCIBILITY :
This bug can be reproduced always.
A DESCRIPTION OF THE PROBLEM :
The javadoc of java.util.stream.Collectors#toMap method starts by referencing the correct java.util.function.Function#identity() method but uses Functions.identity() in the code sample.
* @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
* students to their grade point average:
* <pre>{@code
* Map<Student, Double> studentToGPA
* students.stream().collect(toMap(Functions.identity(),
* student -> computeGPA(student)));
* }</pre>
* And the following produces a {@code Map} mapping a unique identifier to
* students:
* <pre>{@code
* Map<String, Student> studentIdToStudent
* students.stream().collect(toMap(Student::getId,
* Functions.identity());
* }</pre>
REPRODUCIBILITY :
This bug can be reproduced always.
- duplicates
-
JDK-8043327 Collectors.toMap studentToGPA example uses Functions.identity()
-
- Closed
-