Enum customization & export statements #2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi,
I've added two new (small) features that I needed:
This is so I can use them independently, as opposed to as type definitions for other code. To this end I've added a new optional parameter
addExportStatements
. When true,export
statements are added.Secondly, I wanted to be able to customise enum output, so instead of getting ALLCAPS enums, as is the convention in Java/Kotlin, I could have lowercase enums to match my JSON API.
So I've added an
enumTransformer
parameter. It is a function that takes the enum class (KClass<*>
) and the enum value and returns a string. For my task (lowercase enums) I didn't need per-class behaviour, nor is it needed in the default case. However, I thought that some users might want to format some enums differently than others, so I added that as a parameter.If you're happy with the thrust of these changes, I will write unit tests for them as well, if you would like me too. I didn't want to write unit tests for them until I found out whether you were happy with this API/approach.
Thanks for writing a really useful library!