-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEATURE] Generate JSF component properties #2986
Comments
Seems like we eliminate a ton of easily messed up boilerplate in trade for a low maintenance burden. Sounds like a good idea. As for the name:
Or some other combination sounds right. I'm guessing the first one is the better option (fits the Some questions:
Where lombok figures out what to do, per argument (you can have up to one argument of type PropertyKeys, and up to one argument of the key type, with any name and in any order).
I think satisfactory answers are available for all these questions, and armed with those, the feature seems good to go! |
Is there really a convention to use CamelCase for acronyms? What about
|
Yes, adopted by amongst others Oracle/team OpenJDK and google.
Predates the convention. Same for See:
Works for me!
Yup, let's just flat out generate it if needed and not make it configurable. I don't foresee any point in wanting to e.g. not generate it.
My primary concern is that users of this feature will make an assumption about how it works and will consider their assumption so obvious that they'd be highly surprised if it worked differently than what they think it does. Except, there are non-trivial amounts of programmers with that idea making different assumptions. I'm not sure there's any solution there other than to just accept that some folks will get confused and a little angry that 'lombok made such a dumb choice', and all we get to do is pick which group gets angry. One way out is to only allow literally constant literals, and not even refs to constants (because we need resolution to know), but that feels needlessly restrictive. Copying the initializer though... not so sure we can do that. Expressions can contain almost all syntax nodes, as
Okay, let's do exactly that and not make it configurable.
Okay, that means the feature will error out and link to the docs if you put the annotation on a top-level typedef. |
Describe the feature
A JSF component usually uses an enum to list all its properties. For each of the enumerated properties there is a getter and a setter which refers to the state helper to store the value.
Real world example: https://github.com/primefaces/primefaces/blob/9f8f972a1a549759859f684b4c221436c0ed93e2/primefaces/src/main/java/org/primefaces/component/selectonemenu/SelectOneMenuBase.java
Writing all that by hand is quite annoying and error prone (It took me more than an hour to figure out that I missed to adjust one property key in my copy pasted setter).
I propose to add an annotation (e.g.
@JSFComponentProperties
) that can be added to inner classes. It transforms the whole class into an enum using the field names, uses the field types for getter and setter types and moves the initializer to the default value. Some special handling for primitive types without initializers is required.Example to generate the code above:
Describe the target audience
JSF developers
Additional context
Most of this should be quite easy, converting a class into an enum might be a little bit harder.
The text was updated successfully, but these errors were encountered: