I'm generating java class files using org.apache.cxf:cxf-xjc-plugin from an xsd. I'm using the global binding typesafeEnumMemberName="generateName"
so the plugin generates member names for the enum class when the plugin cannot create a valid Java identifier for a member of the enumeration.
My question is:
Is there a way to alter the way these typesafe enum member names are generated?
For example, alter it to include the value? This so the member represents the value in stead of just an incremental number.
Additional info:
The xsd I have specifies the following simpleType:
<xs:simpleType name="CodeBurgelijkeStaat">
<xs:annotation>
<xs:documentation>COD366_NEN</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:enumeration value="0">
<xs:annotation>
<xs:documentation>Onbekend</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="1">
<xs:annotation>
<xs:documentation>Ongehuwd en geen geregistreerd partner en nooit gehuwd of geregistreerd partner geweest</xs:documentation>
</xs:annotation>
</xs:enumeration>
</xs:restriction>
</xs:simpleType>
Which results in the following class:
@XmlType(name = "CodeBurgelijkeStaat")
@XmlEnum
public enum CodeBurgelijkeStaat {
/**
* Onbekend
*
*/
@XmlEnumValue("0")
VALUE_1("0"),
/**
* Ongehuwd en geen geregistreerd partner en nooit gehuwd of geregistreerd partner geweest
*
*/
@XmlEnumValue("1")
VALUE_2("1");
private final String value;
CodeBurgelijkeStaat(String v) {
value = v;
}
public String value() {
return value;
}
public static CodeBurgelijkeStaat fromValue(String v) {
for (CodeBurgelijkeStaat c: CodeBurgelijkeStaat.values()) {
if (c.value.equals(v)) {
return c;
}
}
throw new IllegalArgumentException(v);
}
}