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

enum used as a key does not work

    XMLWordPrintable

Details

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

    • 5788

    Description

      In my YANG model, I'm using an enum leaf as key. That passes POJO generation, but fails the Java compilation. For instance, if I use the following perfectly valid model, it fails mvn build (when I use Beryllium-SR1 yangtools).

      module model1 {
      namespace "model1";
      prefix "model1";
      revision 2016-04-21 { }

      grouping A {
      leaf B {
      type enumeration {
      enum X {}
      enum Y {}
      }
      }
      }

      container C {
      list D

      { key "B"; uses A; }

      }
      }

      mvn compilation generates the following error.

      [INFO] -------------------------------------------------------------
      [ERROR] COMPILATION ERROR :
      [INFO] -------------------------------------------------------------
      [ERROR] model/src/main/yang-gen-code/org/opendaylight/yang/gen/v1/model1/rev160421/c/DBuilder.java:[40,32] incompatible types: java.lang.Enum cannot be converted to org.opendaylight.yang.gen.v1.model1.rev160421.A.B
      [ERROR] model/src/main/yang-gen-code/org/opendaylight/yang/gen/v1/model1/rev160421/c/DBuilder.java:[150,36] incompatible types: java.lang.Enum cannot be converted to org.opendaylight.yang.gen.v1.model1.rev160421.A.B
      [INFO] 2 errors
      [INFO] -------------------------------------------------------------

      When I look deeper into the code generated, I see that DKey generates with the field of type Enum instead of type B (which is what DBuilder.java is expecting). The only way to get pass this issue is to define the enumeration separately as a typedef. If I do that, things work fine.

      Attachments

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

        Activity

          People

            filip.gregor@pantheon.tech Filip Gregor
            srini.seetharaman@gmail.com Srini Seetharaman
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: