Example of a Java custom enumeration converter
- 2020-04-01 03:23:26
- OfStack
Java custom enumeration converters
import org.apache.commons.beanutils.Converter;
public class MyEnumConverter implements Converter {
@Override
//Converts value to type c -- enumerate generic converters
public Object convert(Class c, Object value) {
String strVal = (String) value;
//Equivalent to Type. The valueOf (strVal);
return Enum.valueOf(c, strVal);
}
}