I want to create an Enum editor, which takes an Enum type as its generic. E is a generic type, but restricted to be an Enum type. How can I get the values of the Enum class from the instance e?
public class ComboBoxEnumEditor<E extends Enum<E>>{
public ComboBoxEnumEditor(E e) {
// how to get values of E from e?
// attemp1:
List values = e.getClass().values();
// attemp2:
List values = ((Enum.class)e.getClass()).values();
// attemp3:
List values = ((Enum.class)e.getClass()).values();
// none of the above works...
}
}
Say I have an Enum
public enum Location {
Default( false, EAttributeLocation.MAIN_TABLE_IF_AVAILABLE ),
Main( false, EAttributeLocation.MAIN_TABLE ),
Overflow( false, EAttributeLocation.OVERFLOW_TABLE ),
Separate( false, EAttributeLocation.SEPARATE_TABLE );
......
}
I want my ComboBoxEnumEditor be able to do
{
ComboBoxEnumEditor(new Location());
}
Please help, thanks.