On Tue, 4 Feb 2025 19:34:29 GMT, Michael Strauß <[email protected]> wrote:
>> modules/javafx.base/src/main/java/com/sun/javafx/PreviewFeature.java line 37:
>>
>>> 35: * has opted into preview features.
>>> 36: */
>>> 37: public enum PreviewFeature {
>>
>> Why enum?
>> Maybe use a regular class with a public constructor should do it.
>> What do you think?
>
> The idea is to make it easy and obvious to use from preview code:
>
> PreviewFeature.MY_PREVIEW_FEATURE.checkEnabled();
>
> In addition to that, any IDE can easily list all uses of an enum constant,
> which gives you an overview where APIs of a particular feature are located.
> After all, enums are just regular classes with singleton instances.
>
> By the way, preview features can't be individually enabled or disabled. The
> point of checking on a enum constant is to generate an appropriate error
> message (including the name of the feature) in case the user didn't enable
> preview features.
my only objection is that enum implies the use of a switch pattern, which is
not really applicable here.
since it's in com.sun.* hierarchy and only intended for jfx devs, I am fine
with enum.
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/1359#discussion_r1941790951