The typesafe enumeration declarations provide a localized way to map XML simpleType elements to Java typesafe enum classes. There are two types of typesafe enumeration declarations you can make:
<typesafeEnumClass> lets you map an entire simpleType class to typesafe enum classes.
<typesafeEnumMember> lets you map just selected members of a simpleType class to typesafe enum classes.
In both cases, there are two primary limitations on this type of customization:
Only simpleType definitions with enumeration facets can be customized using this binding declaration.
This customization only applies to a single simpleType definition at a time. To map sets of similar simpleType definitions on a global level, use the typesafeEnumBase attribute in a <globalBindings> declaration, as described in Global Binding Declarations.
The syntax for the <typesafeEnumClass> customization is:
<typesafeEnumClass [ name = "enumClassName" ] [ <typesafeEnumMember> ... </typesafeEnumMember> ]* [ <javadoc> enumClassJavadoc </javadoc> ] </typesafeEnumClass>
name must be a legal Java Identifier, and must not have a package prefix.
You can have zero or more <typesafeEnumMember> declarations embedded in a <typesafeEnumClass> declaration.
<javadoc> customizes the Javadoc tool annotations for the enumeration class.
The syntax for the <typesafeEnumMember> customization is:
<typesafeEnumMember name = "enumMemberName"> [ value = "enumMemberValue" ] [ <javadoc> enumMemberJavadoc </javadoc> ] </typesafeEnumMember>
name must always be specified and must be a legal Java identifier.
value must be the enumeration value specified in the source schema.
<javadoc> customizes the Javadoc tool annotations for the enumeration constant.
For inline annotations, the <typesafeEnumClass> declaration must be specified in the annotation element of the <simpleType> element. The <typesafeEnumMember> must be specified in the annotation element of the enumeration member. This allows the enumeration member to be customized independently from the enumeration class.
For information about typesafe enum design patterns, see the sample chapter of Joshua Bloch’s Effective Java Programming on the Java Developer Connection.