This content has been marked as final. Show 4 replies
Those values don't resemble each other in the slightest (e.g. "A8_BIT_DATA" and "A8_BIT_DATA_BUS"). are you sure you are looking at the right files?
Sorry I mistyped my XML in the original post. I have corrected it.
That's very weird, i've never seen jaxb insert extra '_' like that. that said, you can control the enum name using the jaxb extensions like so:1 person found this helpful
<schema xmlns:jxb="http://java.sun.com/xml/ns/jaxb" jxb:version="2.0"> <simpleType name ="DataWidthEnum"> <annotation> <appinfo> <jxb:typesafeEnumClass> <jxb:typesafeEnumMember name="A8_BIT_DATA_BUS" value="A8_BIT_DATA_BUS" /> <jxb:typesafeEnumMember name="A16_BIT_DATA_BUS" value="A16_BIT_DATA_BUS" /> </jxb:typesafeEnumClass> </appinfo> </annotation> <restriction base="string"> <enumeration value="A8_BIT_DATA_BUS"/> <enumeration value="A16_BIT_DATA_BUS"/> </restriction> </simpleType> </xs:schema>
Thanks jtahlborn that looks like what I was looking for.
On another note, looking at the generated code more closely (like I probably should have done in the first place), I notice that the original name used in the schema is kept in the enum and accessible via a generated value() method (equivalent to the name() method if the extra underscore hadn't been inserted) and is reversible from a fromValue() method (equivalent to the valueOf() method if the extra underscore hadn't been inserted.) I also see that these methods are generated in other classes where the underscore insertion isn't done, but just as wrappers of the name() and valueOf() methods instead. As a result I can just use the value() fromValue methods everywhere in dealing with generated enums and my issue will be addressed.
Thanks everyone for your input!