I'm using JAXB to generate classes from an XML schema.
I have two simpleTypes with String restrictions to specific enumeration values as follows:
Although no essencial differences are apparent, the JAXB generates an enum from the first one:
whereas the second type is handled as a simple string (the following is taken from a class that is generated by JAXB and contains an element of the second type):
Any ideas?
I have two simpleTypes with String restrictions to specific enumeration values as follows:
Code:
<xs:simpleType name="RestDaysHandlingMode"> <xs:restriction base="xs:string"> <xs:enumeration value="Forward"></xs:enumeration> <xs:enumeration value="ForwardUnlessMonthChange"></xs:enumeration> <xs:enumeration value="NoShift"></xs:enumeration> </xs:restriction> </xs:simpleType> <xs:simpleType name="YearMonthMethod"> <xs:restriction base="xs:string"> <xs:enumeration value="30_360"></xs:enumeration> <xs:enumeration value="Actual_360"></xs:enumeration> <xs:enumeration value="Actual_365"></xs:enumeration> <xs:enumeration value="Actual_Actual"></xs:enumeration> </xs:restriction> </xs:simpleType>
Code:
@XmlEnum public enum RestDaysHandlingMode { @XmlEnumValue("Forward") FORWARD("Forward"), @XmlEnumValue("ForwardUnlessMonthChange") FORWARD_UNLESS_MONTH_CHANGE("ForwardUnlessMonthChange"), @XmlEnumValue("NoShift") NO_SHIFT("NoShift"); private final String value; RestDaysHandlingMode(String v) { value = v; } public String value() { return value; } public static RestDaysHandlingMode fromValue(String v) { for (RestDaysHandlingMode c: RestDaysHandlingMode.values()) { if (c.value.equals(v)) { return c; } } throw new IllegalArgumentException(v); } }
whereas the second type is handled as a simple string (the following is taken from a class that is generated by JAXB and contains an element of the second type):
Code:
/** * Gets the value of the yearMonthMethod property. * * @return * possible object is * {@link String } * */ public String getYearMonthMethod() { return yearMonthMethod; }
Comment