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

Create Collector which merges results of two other collectors

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 12
    • None
    • core-libs
    • None

      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> teeing(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.

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

              Created:
              Updated:
              Resolved: