On Fri, 17 Nov 2023 20:01:55 GMT, Alexey Ivanov <aiva...@openjdk.org> wrote:

> Enhance `PassFailJFrame` for single-window test UI which is the most common 
> case so that there's no need to return `List.of`.
> 
> With this change, the lambda or method reference passed to `Builder.testUI` 
> will return Window instead of `List<Window>` (or `List<? extends Window>`.
> 
> This change adds new functional interface `WindowCreator` which returns a 
> single Window; the existing interface is renamed to `WindowListCreator`.
> 
> It's backwards compatible change; the 
> [FileChooserSymLinkTest.java](https://github.com/openjdk/jdk/blob/7f47c51aced9c724dbc9b0d8cbd88c49435da460/test/jdk/javax/swing/JFileChooser/FileChooserSymLinkTest.java)
>  test which uses `Builder.testUI` works without change.
> 
> It was my main concern that it will be impossible to have two interfaces 
> where one creates a `Windows` and another — `List<Windows>`. The Java 
> compiler automatically selects the correct method based on the return type of 
> the lambda expression, so that both cases are supported. The requirement to 
> return a `List` where only one window is needed bothered me, and I finally 
> solved it.
> 
> In addition to that, I added description to all the overloads of the 
> `Builder.testUI` method and updated the sample in the class documentation.
> 
> Since the `PassFailJFrame` class isn't supposed to be extended, I marked it 
> `final` to prevent anyone from doing it.

This pull request has now been integrated.

Changeset: 83ffc1ac
Author:    Alexey Ivanov <aiva...@openjdk.org>
URL:       
https://git.openjdk.org/jdk/commit/83ffc1ac94b8893532d8663b9058592f1714d337
Stats:     152 lines in 1 file changed: 125 ins; 6 del; 21 mod

8320303: Allow PassFailJFrame to accept single window creator

Reviewed-by: serb

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

PR: https://git.openjdk.org/jdk/pull/16717

Reply via email to