Hi folks,
I've tries the following fragment:
<xs:element name="SexType">
<xs:complexType>
<xs:sequence>
<xs:element name="sex">
<xs:simpleType>
<xs:annotation>
<xs:appinfo>
<jaxb:typesafeEnumClass name="sex">
<jaxb:typesafeEnumMember name="MALE" value="MA LE" />
<jaxb:typesafeEnumMember name="FEMALE" value="FEM ALE" />
</jaxb:typesafeEnumClass>
</xs:appinfo>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:enumeration value="MA LE" />
<xs:enumeration value="FEM ALE" />
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
And got the following code generated:
/**
* <p>Java class for anonymous complex type.
*
* <p>The following schema fragment specifies the expected content
contained within this class.
*
* <pre>
* <complexType>
* <complexContent>
* <restriction base="{
http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="sex">
* <simpleType>
* <restriction base="{
http://www.w3.org/2001/XMLSchema}string">
* <enumeration value="MA LE"/>
* <enumeration value="FEM ALE"/>
* </restriction>
* </simpleType>
* </element>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"sex"
})
@XmlRootElement(name = "SexType")
@Entity(name = "org.jvnet.hyperjaxb3.ejb.tests.cuone.SexType")
@Table(name = "SEXTYPE")
@Inheritance(strategy = InheritanceType.JOINED)
public class SexType
implements Equals, HashCode
{
@XmlElement(required = true)
protected SexType.Sex sex;
@XmlAttribute(name = "Myid")
protected Long myid;
/**
* Gets the value of the sex property.
*
* @return
* possible object is
* {_at_link SexType.Sex }
*
*/
@Basic
@Column(name = "SEX")
@Enumerated(EnumType.STRING)
public SexType.Sex getSex() {
return sex;
}
/**
* Sets the value of the sex property.
*
* @param value
* allowed object is
* {_at_link SexType.Sex }
*
*/
public void setSex(SexType.Sex value) {
this.sex = value;
}
/**
* Gets the value of the myid property.
*
* @return
* possible object is
* {_at_link Long }
*
*/
@Id
@Column(name = "MY_ID")
@GeneratedValue(strategy = GenerationType.AUTO)
public Long getMyid() {
return myid;
}
/**
* Sets the value of the myid property.
*
* @param value
* allowed object is
* {_at_link Long }
*
*/
public void setMyid(Long value) {
this.myid = value;
}
public void equals(Object object, EqualsBuilder equalsBuilder) {
if (!(object instanceof SexType)) {
equalsBuilder.appendSuper(false);
return ;
}
if (this == object) {
return ;
}
final SexType that = ((SexType) object);
equalsBuilder.append(this.getSex(), that.getSex());
}
public boolean equals(Object object) {
if (!(object instanceof SexType)) {
return false;
}
if (this == object) {
return true;
}
final EqualsBuilder equalsBuilder = new JAXBEqualsBuilder();
equals(object, equalsBuilder);
return equalsBuilder.isEquals();
}
public void hashCode(HashCodeBuilder hashCodeBuilder) {
hashCodeBuilder.append(this.getSex());
}
public int hashCode() {
final HashCodeBuilder hashCodeBuilder = new JAXBHashCodeBuilder();
hashCode(hashCodeBuilder);
return hashCodeBuilder.toHashCode();
}
/**
* <p>Java class for null.
*
* <p>The following schema fragment specifies the expected content
contained within this class.
* <p>
* <pre>
* <simpleType>
* <restriction base="{
http://www.w3.org/2001/XMLSchema}string">
* <enumeration value="MA LE"/>
* <enumeration value="FEM ALE"/>
* </restriction>
* </simpleType>
* </pre>
*
*/
@XmlType(name = "")
@XmlEnum
public enum Sex {
@XmlEnumValue("MA LE")
MALE("MA LE"),
@XmlEnumValue("FEM ALE")
FEMALE("FEM ALE");
private final String value;
Sex(String v) {
value = v;
}
public String value() {
return value;
}
public static SexType.Sex fromValue(String v) {
for (SexType.Sex c: SexType.Sex.values()) {
if (c.value.equals(v)) {
return c;
}
}
throw new IllegalArgumentException(v);
}
}
}
So from my perspective everything works just fine.
Bye.
/lexi