[MAGNOLIA-5627] Node2Bean: support enums case-insensitively Created: 15/Jan/14 Updated: 11/Aug/16 Resolved: 17/Jan/14 |
|
| Status: | Closed |
| Project: | Magnolia |
| Component/s: | content2bean, core |
| Affects Version/s: | None |
| Fix Version/s: | 5.2.2 |
| Type: | Improvement | Priority: | Neutral |
| Reporter: | Magnolia International | Assignee: | Magnolia International |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | maintenance | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
||||||||||||||||||||||||||||
| Issue Links: |
|
||||||||||||||||||||||||||||
| Template: |
|
||||||||||||||||||||||||||||
| Patch included: |
Yes
|
||||||||||||||||||||||||||||
| Acceptance criteria: |
Empty
|
||||||||||||||||||||||||||||
| Task DoD: |
[ ]*
Doc/release notes changes? Comment present?
[ ]*
Downstream builds green?
[ ]*
Solution information and context easily available?
[ ]*
Tests
[ ]*
FixVersion filled and not yet released
[ ] 
Architecture Decision Record (ADR)
|
||||||||||||||||||||||||||||
| Testcase included: |
Yes
|
||||||||||||||||||||||||||||
| Release notes required: |
Yes
|
||||||||||||||||||||||||||||
| Description |
|
With There seems to be some debate as to wether enum consts should be declared in ALL_UPPERCASE (which follows Java coding conventions) or in camelCase (which imo is often more readable, elegant, and doesn't seem as odd when the enum actually as methods and/or implements an interface) There is however hardly any debate as to whether the ALL_UPPERCASE ones look ugly in configuration trees. (it seems more natural to configure them "like" other properties are configured, especially when next to String properties). And in the case of enums not under our control (i.e when configuring a 3rd party object), having mixed cases makes the tree even more "ugly". To avoid the debate altogether, I propose that we implement a case-insensitive converter for Enums in Node2Bean. Here's a patch with tests (as well as some commented out tests of alternative implementations which turned out to be significantly slower) I'd like to introduce this with 5.3. One of the concrete use-case I see is for auto-complete in select fields of 5.x : info.magnolia.ui.form.field.definition.SelectFieldDefinition has a filteringMode property which can be used just for that, but is currently using an int for it's various values. It would benefit from using the enum name, but this enum is a Vaadin class - we can't enforce how they decide to name their consts As far as I can tell, this could even be included in a patch release, as it should have no side-effect. In the unlikely case that an enum has several consts with the same-name-except-case (MyEnum.foo, MyEnum.FOO), this patch favors exact-case first, anyway. |