-
Notifications
You must be signed in to change notification settings - Fork 162
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
Using enums with a body as a Map key #643
Comments
🤯 Didn't know that. I personally use enums implementing an interface or having methods quite often, they really good as singletons. I'm gonna fix this ASAP. |
Thanks for fixing that. Yes I was quite surprised too; I was using enums to define my fields, then added a method for special data migration for a field, and then it seems it was no longer an enum!?! 😃 |
That lead to a very interesting thread: https://twitter.com/rotnroll666/status/1146316196876378112 Especially https://twitter.com/jddarcy/status/1146512532296699904 Also Brians and Stuarts answers. I learned a ton. |
Yes, interesting. Guess its pretty hard working on the JVM, an awful lot of things to think about. I guess it is technically correct, but is a surprising result for the function, I'd think there wouldn't be many people who would want it to return false when dealing with an Enum with a function, but that was the choice. |
Expected Behavior
When using a Map with an enum key, if one of the Enums has a body (i.e. a method defined in the individual enum declaration); the enum should still be able to be used as a key.
Current Behavior
Currently the MapCompositeConverter does not count this enum value as an enum.
Possible Solution
This change: master...mattharr:master
Looks to fix the issue, I looked at https://stackoverflow.com/questions/4166488/checking-if-a-class-is-java-lang-enum when looking into it.
However/additionally I think there may be other places in the codebase that use isEnum that could potentially have the same issue, but I wasn't sure.
Steps to Reproduce (for bugs)
This is when using an enum like:
Your Environment
The text was updated successfully, but these errors were encountered: