-
Improvement
-
Resolution: Fixed
-
Neutral
-
None
-
-
Yes
-
Empty show more show less
-
Yes
-
Yes
With MAGNOLIA-2734 (Magnolia 4.1) we introduced support for enums in Content2Bean.
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.
- is depended upon by
-
MGNLUI-2841 Let filteringMode be configured on Select fields
- Closed
- is superseded by
-
MAGNOLIA-6747 Export EnumCaseInsensitive from node2bean to info.magnolia.util
- Closed
- relates to
-
MAGNOLIA-2734 Provide enum support in content2bean
- Closed
-
MAGNOLIA-5887 Node2Bean should not try to instantiate enumerations, which causes an exception
- Closed
- mentioned in
-
Wiki Page Loading...