Uploaded image for project: 'Magnolia'
  1. Magnolia
  2. MAGNOLIA-5627

Node2Bean: support enums case-insensitively


    • Yes
    • 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.

        Acceptance criteria

              gjoseph Magnolia International
              gjoseph Magnolia International
              0 Vote for this issue
              1 Start watching this issue