RFR: JDK-8205461 Create Collector which merges results of two other collectors (original) (raw)

Tagir Valeev amaembo at gmail.com
Sun Aug 19 09:24:44 UTC 2018


Hello, Brian!

Of the three phases, teeing is the most important and least obvious, so I think something that includes that in the name is going to be helpful. Perhaps "teeingAndThen" is more evocative and not totally unwieldy.

Ok, sounds acceptable to me. Renamed pairing to teeingAndThen.

> By the way looking into CollectorsTest.java I found some minor things to > cleanup: > 1. .map(mapper::apply) and .flatMap(mapper::apply) can be replaced with > simple .map(mapper) and .flatMap(mapper) respectively Does IntelliJ have an inspection for eliminating such locutions?

Sure, that's how I found them. Well, I took the liberty to fix these two things.

> 2. In many methods redundant throws ReflectiveOperationException is > declared while exception is never thrown For test code where a significant fraction of test cases are going to throw something, we often do this, since its easier to just uniformly tag such methods rather than thinking about which test methods actually throw the exception and which don't. So I think this is harmless (though cleaning it up is harmless too.)

I'm not thinking about this, because my IDE thinks for me :-) Ok, I'll leave them as is for now.

You may want to optimize the EnumSet mechanics for the case where neither collector has interesting characteristics.

Added a special case when reported characteristics for either of collectors are empty or IDENTITY_FINISH only. I think this should be a common case.

The updated webrev is posted here (along with Peter suggestion to rename finisher to merger): http://cr.openjdk.java.net/~tvaleev/webrev/8205461/r3/ Also copyright year is updated

With best regards, Tagir Valeev



More information about the core-libs-dev mailing list