Make simpleType CF_Enumeration iterable
Brought to you by:
pabigot
JAXB has an incredibly useful construct which allows us to take:
<xsd:simpleType name="customerPaymentMethod">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="Credit Card"/>
<xsd:enumeration value="Direct Debit"/>
<xsd:enumeration value="Invoice Only"/>
<xsd:enumeration value="Deferred Payment"/></xsd:restriction>
</xsd:simpleType>
and iterate over the values:
for (CustomerPaymentMethod pm: CustomerPaymentMethod.values()) {
[...]
}
Both PyXB and JAXB allow public access to the constants (CustomerPaymentMethod.CREDIT_CARD / customerPaymentMethod.Credit_Card), which is great. If you could make the list of those iterable and part of the public interface then that would be great.
Agreed. The tricky bit is if doing this involves adding another reserved symbol ("values" in your example) to the enumeration class to provide access to the iterator. Doing that can collide with enumeration values that end up as class constants.
Probably the best way is to make the class itself support iteration. I'll experiment and will probably fix this for the next release (whenever that might be).
Thanks for the suggestion.
commit 5255fe507cb2fa07bd9c8587eb0ed2840ae09403
Author: Peter A. Bigot <pabigot@‌>
Date: Sat Feb 25 16:29:54 2012 -0600