Java custom enumeration converter copy code code is as follows:
import org.apache.commons.beanutils.Converter;
/**
* Custom enumeration converter
*
*
*/
public class MyEnumConverter implements Converter {
@Override
// Convert value to c type --- enumeration universal converter
public Object convert(Class c, Object value) {
String strVal = (String) value;
// Equivalent to Type.valueOf(strVal);
return Enum.valueOf(c, strVal);
}
}