Uploaded image for project: 'mdsal'
  1. mdsal
  2. MDSAL-76

Generated Java Enumerations should contain mapping to the string counter part

    XMLWordPrintable

Details

    • Improvement
    • Status: Resolved
    • Resolution: Done
    • None
    • None
    • None
    • None
    • Operating System: All
      Platform: All

    Description

      The ask:

      As a developer, I want the string value for a given enumeration to be accessible from the generated java binding type, so I can use the raw string value as needed (for example to pass to a southbound plugin).

      Specifically, if we have a type definition like this:

      leaf testEnum {
      type enumeration

      { enum "value-one"; enum "value-two"; }

      }

      today it generates an inner enumeration class like this:

      public enum TestEnum

      { ValueOne(0), ValueTwo(1) ; ... }

      What would be great as it would drastically simplify things, would be for the string value to also be included, and accessible from the generated class. For example, the above type would generate:

      public enum TestEnum {
      ValueOne(0, "value-one"),
      ValueTwo(1, "value-two")
      ;

      String getName()

      { ... }

      static TestEnum forValue( String name ){ ... }

      ...
      }

      . Today the only way to get the mapping is to get the schema context for the module, drill down to the specific definition for the enum, and then manually create a map between the enumPair schema definition and the TestEnum class via the "value".

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              rgoulding Ryan Goulding
              devin.avery@brocade.com Devin Avery
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: