Open david-g-williams opened 4 years ago
The trouble with that type of class is that this is actually not a engineering practice I would recommend.
See https://softwareengineering.stackexchange.com/questions/290006/good-practice-to-hold-constants-in-their-own-file for example.
So encouraging that with it's own annotation seems counterproductive.
On Sun, Oct 4, 2020, 03:59 david-g-williams notifications@github.com wrote:
Many applications need at least on file of constants. These classes often contain exclusively public static final fields, and possibly protected or private members.
This feature request is for an annotation called @Constants https://github.com/Constants, which is like a combination of @UtilityClass https://github.com/UtilityClass and @FieldDefaults(level = AccessLevel.PUBLIC, makeStatic = true, makeFinal = true).
This will save a large vertical column of field access modifiers from these lists of constant values.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/rzwitserloot/lombok/issues/2593, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABIERNDCBSQF5MAH3UGJITSI7JGNANCNFSM4SDMKGYQ .
Beware that it will have the same problem as @UtilityClass with static imports crashing on javac. Instead of making another annotation, it would be better to invest time into meta annotations: https://github.com/rzwitserloot/lombok/issues/557.
I can see that the combination of:
@UtilityClass
@FieldDefaults(level = AccessLevel.PUBLIC, makeFinal = true)
does not work as expected. That could be considered a bug (or missing feature?). I guess that FieldDefaults
runs after UtilityClass
and ignore static fields. Maybe changing the order of the handler could be enough?
Many applications need at least one file of constants. These classes often contain exclusively
public static final
fields, and possiblyprotected
orprivate
members.This feature request is for an annotation called
@Constants
, which is like a combination of@UtilityClass
and@FieldDefaults(level = AccessLevel.PUBLIC, makeStatic = true, makeFinal = true)
, the latter of which does not yet exist with amakeStatic
argument.This will save a large vertical column of field access modifiers from these lists of constant values.