[MDSAL-160] enum used as a key does not work Created: 22/Apr/16  Updated: 09/Mar/18  Resolved: 16/May/16

Status: Resolved
Project: mdsal
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug
Reporter: Srini Seetharaman Assignee: Filip Gregor
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: All


External issue ID: 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.



 Comments   
Comment by Martin Ciglan [ 25/Apr/16 ]

moving to MD-SAL

Comment by Filip Gregor [ 26/Apr/16 ]

proposed fix https://git.opendaylight.org/gerrit/#/c/38106/

Comment by Robert Varga [ 16/May/16 ]

Be: https://git.opendaylight.org/gerrit/#/c/38865/

Generated at Wed Feb 07 20:08:47 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.