Skip to content
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

Add rule for "const": generate Java constants #1627

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

volomas
Copy link

@volomas volomas commented Aug 21, 2024

As of now, generator doesn't take into account "const" keyword.
The value of "const" is simply lost during generation.

In this PR, I've added ConstRule that generates java constant:
public static final <Type> <snake_case_var_name> = <value>.

This allows to use this value in code like this:

var myClass = new GeneratedClass();
myClass.setMyProperty(GeneratedClass.MY_PROPERTY);

... or just when I need to refer to that constant somewhere in the code.

It doesn't set the generated field value to "const" value, because it would mimic "default", so I wasn't sure if that's a good idea.

@volomas volomas force-pushed the const_rule branch 2 times, most recently from f992995 to 5a47f07 Compare August 21, 2024 15:24
Adds rule to generate java constants on "const" properties
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant