On Sat, 26 Sep 2026 10:29:49 GMT, Tagir F. Valeev <[email protected]> wrote:

>> Collectors joiningConjunctively and joiningDisjunctively were added to 
>> Collectors. In addition, we have ListFormat.toCollector to convert any 
>> ListFormat.
>> 
>> For testing, I tested a couple of scenarios and a few corner cases (empty 
>> stream, null element, parallel stream) in a simple non-parameterized JUnit 
>> test. I believe that it's enough, given that the implementation is trivial, 
>> and ListFormat itself, as well as Stream API is already thoroughly tested by 
>> other tests. Tell me if you feel that some testing scenarios are missing, 
>> I'll happily add them.
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Tagir F. Valeev has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   8391789: Empty input test fixed

src/java.base/share/classes/java/text/ListFormat.java line 420:

> 418:         return Collectors.collectingAndThen(
> 419:                 Collectors.mapping(String::valueOf, Collectors.toList()),
> 420:                 input -> input.isEmpty() ? "" : format(input));

If this proposal goes ahead then I assume the prototype implementation will be 
replaced. It looks like the most efficient way would be for the accumulator to 
accumulate in a StringBuilder for the "middle elements", with the finishing 
handling the 0, 1, 2, 3 and > 3 cases.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/32716#discussion_r4144230365

Reply via email to