Skip to content

enums: allow custom to string implementations - #34

Open
dirkredeye wants to merge 1 commit into
keepcosmos:masterfrom
dirkredeye:patch-1
Open

enums: allow custom to string implementations#34
dirkredeye wants to merge 1 commit into
keepcosmos:masterfrom
dirkredeye:patch-1

Conversation

@dirkredeye

@dirkredeye dirkredeye commented Oct 14, 2019

Copy link
Copy Markdown

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.

1 participant