On Fri, 4 Feb 2022 14:20:59 GMT, Alexey Ivanov <[email protected]> wrote:

>> test/jdk/javax/swing/JButton/4659800/EnterKeyActivatesButton.java line 96:
>> 
>>> 94:                 .filter(laf -> laf.getName().startsWith("Windows"))
>>> 95:                 .map(laf -> laf.getClassName())
>>> 96:                 .collect(Collectors.toList());
>> 
>> Just a note. You can align the chained calls with the first `.stream` one. 
>> Here, it nearly fits into 80-column limit and doesn't exceed 100-column 
>> limit. I don't know if there are any guidelines in this regard for 
>> java.desktop module. It's up to you.
>> 
>> IDE recommends replacing `.collect(Collectors.toList()` with `.toList()` — 
>> looks cleaner, doesn't it?
>> 
>> It also recommends replacing lambda expression `laf -> laf.getClassName()` 
>> with method reference `UIManager.LookAndFeelInfo::getClassName`, yet the 
>> former seems to convey the intent clearer.
>
> I can't find your comment that you can't find `.toList()`.
> 
> The 
> [`toList`](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/stream/Stream.html#toList())
>  method in `Stream` is available since Java 16 only.
> 
> I was referring to this method rather than static import of 
> `Collectors.toList` but it's fine.
> 
> Using `Collectors.toList` makes backporting, if you're planning it, easier. 
> If you don't plan backporting, then using the newly added method sounds 
> better to me.

Yes, I'm planning to backport it to lower releases, so I'm keeping this as 
such. I deleted that comment because I thought you may be mentioning about that 
static import.

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

PR: https://git.openjdk.java.net/jdk/pull/7296

Reply via email to