Skip to content
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

enums: allow custom to string implementations #34

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dirkredeye
Copy link

@dirkredeye dirkredeye commented Oct 14, 2019

As per the enum spec

  • name() is final and can't change. It refers to the exact defined name of the constant, as declared in the enum.
  • toString() is arbitrary and can be developer overridden. It defaults to name()

So, this should use name() instead of toString(), in-case a developer (today, me) overrides the toString of an enum.

Also removes some strange behaviour with _- in enums?

As per the [enum spec](https://docs.oracle.com/javase/7/docs/api/java/lang/Enum.html)
* name() is final and can't change. It refers to the exact defined name of the constant, as declared in the enum.
* toString() is arbitrary and can be developer overridden. It defaults to name()

So, this should use name() instead of toString(), in-case a developer (today, me) overrides the toString of an enum.
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.

None yet

1 participant