On Wed, 1 Nov 2023 03:25:50 GMT, Michael Strauß <mstra...@openjdk.org> wrote:

>> modules/javafx.graphics/src/main/java/javafx/application/Platform.java line 
>> 636:
>> 
>>> 634:          *         if no mapping exists for the specified key
>>> 635:          */
>>> 636:         Optional<Double> getDouble(String key);
>> 
>> I'm a bit confused about this and similar methods. Several points:
>> 
>> 1. There is no value that is a `Double`, and also no `Paint`, so I'm not 
>> sure what these are for considering that list gives all possible valid 
>> entries.
>> 
>> 2. If the list of keys in the table is fully known, wouldn't an enum make 
>> more sense and be more safe than of a `String`?
>
> 1. There is no `Double` value now, but there might be in the future. For 
> exampe, the API may expose system-provided double-click times, or it may 
> expose information about the dimensions of system decorations. As for 
> `Paint`, it might be conceivable that a platform would expose color gradients.
> 
> 2. The list is only fully known for the three listed platforms, but it's 
> unknown for other platforms. Using an enum key instead of a string key is 
> certainly possible, but then we'd be hard-coding platform-specific constants 
> into the core of JavaFX. You might argue that providing a list of supported 
> keys isn't really all that different from using a language feature like enums 
> to represent the constants. Using platform-specific preferences requires a 
> deep understanding of the platform in any case, and is not something 
> application developers should rely on regularly. Instead, they should be 
> using the common subset of well-known preferences, which is easily accessible 
> via the properties on the `Platform` class.

Alright, my assumption that the listed keys are complete is wrong then. I 
thought that "The following list contains all preferences that are potentially 
available on the specified platforms" was a good enough guarantee.

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

PR Review Comment: https://git.openjdk.org/jfx/pull/1014#discussion_r1378771358

Reply via email to