How can I access static method of the enum if given enum is a parameter of generic class?
Consider following example
public class EnumListBox<T extends Enum<T>> extends ListBox implements LeafValueEditor<T>
{
@Override
public void setValue(T value)
{
// something..
}
@Override
public T getValue()
{
int ndx = getSelectedIndex();
String val = getValue(ndx);
return T.valueOf(val);
}
}
For some reason Enum<?>.valueOf(String) is not available to me. Another version of this method has two parameters and wants Class<Enum<?>> which I can’t instantiate as T.class.
How would you fix this? Basically I want to have universal ListBox wrapper for any enum.
The easiest fix is to pass an instance of the enum class in the constructor for
EnumListBox.