Skip to content

Revise EnumToStringConverter to use Enum#toString instead of Enum#name #34630

@MarcoMartins86

Description

@MarcoMartins86

My problem with the current EnumToStringConverter is that it doesn't put in the hands of the coder the decision on how to represent the Enum value (at least easily). It uses the .name() instead of the .toString(), so one cannot override it.

I have a workaround, make a custom converter and register it. Although, it can get cumbersome if I need to do this for multiple enums.

My point is, why not use the .toString() method, by default it will use the .name(), and if the coder wants to change it, simply overrides the .toString() and returns whatever he wants.

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)status: declinedA suggestion or change that we don't feel we should currently apply

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions