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

Create Collector which merges results of two other collectors

    Details

    • Type: Enhancement
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:
      None

      Description

      Add a new Collector into Collectors class which merges results of two other collectors. One API method should be added (name is subject to discussion):

      public static <T, R1, R2, R>
          Collector<T, ?, R> pairing(Collector<? super T, ?, R1> c1,
                                     Collector<? super T, ?, R2> c2,
                                     BiFunction<? super R1, ? super R2, ? extends R> finisher);

      Every stream element should be passed to both collectors c1 and c2. To compute a final result, a finisher function is called which combines the results of two individual collectors.

        Attachments

          Activity

            People

            • Assignee:
              tvaleev Tagir Valeev
              Reporter:
              tvaleev Tagir Valeev
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: