-
Notifications
You must be signed in to change notification settings - Fork 0
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
Enum mapping in provided bindings #6
Comments
Good idea, this should be very straight-forward to implement. I don't think there is need for reflection or additional interfaces, I'll just use |
Well, by convention every enum constant is unique by its constant name in upper case. public enum Sample {
test,
TEST
} So calling |
Yes, that is the issue with this idea. On the other hand, making it very strict might result in the need to make own mapper implementations that are more convenient for end users in many cases. |
EnumMappers are now part of the provided bindings and they use strict parsing. However, I also made it easier to request the mapping of different arguments, simplifying such things as string transformers, should you need them. |
What are your thoughts on adding a default mapping for enums to
ProvidedBindings
?Describe the solution you'd like
I already tried to do so here in an other project.
In this approach the argument will be mapped by the enum constant.
Describe alternatives you've considered
Another idea is to assume that the enum has two methods
enum fromText(arg : String)
andString toText()
that will be called by reflections.I'm not sure on how the performance will be influenced by reflection calls. So another idea would be to assume that the enum implements an interface with those methods. This would only work for enums, that are written by the end-user and not existing ones (obviously).
The text was updated successfully, but these errors were encountered: