Skip to content

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

Open
volomas wants to merge 2 commits intojoelittlejohn:masterfrom
volomas:const_rule
Open

Add rule for "const": generate Java constants#1627
volomas wants to merge 2 commits intojoelittlejohn:masterfrom
volomas:const_rule

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