Java – How to get all Enum values in XMLBeans


Apache XMLBeans can be used to generate Java classes and interfaces from XML Schema Definition files (XSD). It also generates Enums based on StringEnumAbstractBase and StringEnumAbstractBase.Table to represent domain values. They are handy for entering only valid values. However, I want to get all those values to generate a JCombobox, a JTable or a html table.

Is there a XMLBeans API call to get all Enum values from a generated class?
Is the only choice available some sort of Java reflection?


Best Solution

This worked for me:

for (int i = 1; i <= MyEnum.Enum.table.lastInt(); i++)