[MDSAL-76] Generated Java Enumerations should contain mapping to the string counter part Created: 19/Mar/15 Updated: 09/Mar/18 Resolved: 10/Mar/17 |
|
| Status: | Resolved |
| Project: | mdsal |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | ||
| Reporter: | Devin Avery | Assignee: | Ryan Goulding |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Operating System: All |
||
| Issue Links: |
|
||||||||
| 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 { } 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 { 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". |
| Comments |
| Comment by Robert Varga [ 19/Mar/15 ] |
|
This is a change to the bindings specification, although compatible. Targetting to next release as we are just a few hours from API freeze. |
| Comment by Ryan Goulding [ 01/Jun/16 ] |
|
It looks like this is already part of the binding spec; am I missing something: |
| Comment by Ryan Goulding [ 01/Jun/16 ] |
|
Nevermind a quick test proved otherwise. This will require exposing the "raw" data from yangtools and then outputting in mdsal binding generator. I have a draft change in the works that appears to work. |
| Comment by Robert Varga [ 20/Jun/16 ] |
|
https://git.opendaylight.org/gerrit/39733 |