Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8166877

Javadoc of java.util.stream.Collectors#toMap points to Functions.identity() instead of Function.identity()

XMLWordPrintable

      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.

            psonal Pallavi Sonal (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: