On Tue, 31 Oct 2023 22:33:00 GMT, Nir Lisker <nlis...@openjdk.org> wrote:

>> Michael Strauß has updated the pull request incrementally with two 
>> additional commits since the last revision:
>> 
>>  - formatting
>>  - Javadoc change
>
> 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.

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

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

Reply via email to