Hi, Naoto! Thank you for creating an RFE. I can work on this if you don't mind.
With best regards, Tagir Valeev On Thu, Sep 3, 2026 at 10:06 PM Naoto Sato <[email protected]> wrote: > > Hi Tagir, > > Thanks. That seems like a useful suggestion. I hadn't considered using > it with streams. > > Filed an RFE: https://bugs.openjdk.org/browse/JDK-8391789 > > Naoto > > On 9/3/26 12:37 AM, Tagir Valeev wrote: > > Hello! > > > > I recently discovered the java.text.ListFormat API which appeared since > > Java 22. It's great and useful, but I feel that it misses a Collector. > > It's very possible that the original strings are available in the > > Stream, rather than in the List, and it would be nice to be able to join > > the stream directly, without intermediate List, like we can do with > > Collectors.joining(). So I would propose adding a new instance method to > > ListFormat, like > > > > public Collector<String, ?, String> formatting() {...} > > > > or probably, to be more consistent with Collectors.joining(), it could be > > > > public Collector<CharSequence, ?, String> formatting() {...} > > > > The initial implementation could be trivial: > > > > public Collector<CharSequence, ?, String> formatting() { > > return > > Collectors.collectingAndThen(Collectors.mapping(CharSequence::toString, > > Collectors.toList()), this::format); > > } > > > > Or without 'mapping' step, if we want to limit the input to strings. > > > > What do you think? > > > > With best regards, > > Tagir Valeev >
