Skip to content

Added setting for formatting enum keys in pascal case #587

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

Merged

Conversation

jrparish
Copy link
Contributor

@jrparish jrparish commented Dec 3, 2020

Our API team likes to use UNDERSCORE_CASE enums, but UI team prefers the more readable pascal casing.

This adds an optional setting to format the keys accordingly.

@vojtechhabarta vojtechhabarta merged commit 323c173 into vojtechhabarta:master Dec 6, 2020
@vojtechhabarta
Copy link
Owner

Thanks for this feature. I think it is nice so I am merging it but I will push few changes.

Firstly I am adding enumMemberCasing parameter (instead of special parameter for Pascal case). This parameter can support not only "PascalCase" but also "camelCase" and possibly others. Since configuration parameters should be usable from build plugins (Maven, Gradle) I am adding this new parameter there as well. There is also description which is used when generating documentation. Here is an example of usage from Maven:

<configuration>
    ...
    <mapEnum>asEnum</mapEnum>
    <enumMemberCasing>PascalCase</enumMemberCasing>
    ...
</configuration>

Next are some improvements in splitting identifier into words using regular expression. It should now support letters other than A-Z and numbers should be treated as words. I am still not sure it supports all cases well but at least I added unit test specifically for this part so we can easily test and improve other cases.

Could you please check my changes if the feature works as expected?

vojtechhabarta added a commit that referenced this pull request Dec 6, 2020
- `enumMemberCasing` parameter (including Maven and Gradle plugins)
- improvements in splitting into words
@jrparish jrparish deleted the feature/enum-to-pascal-case branch December 7, 2020 15:39
@jrparish
Copy link
Contributor Author

jrparish commented Dec 7, 2020

That looks great, thank you!

@vojtechhabarta
Copy link
Owner

Released in v2.28.785.

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.

2 participants