com.bixuebihui.jdbc.EnumConverter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of c-dbtools Show documentation
Show all versions of c-dbtools Show documentation
a fast small database connection pool and a active record flavor mini framework
package com.bixuebihui.jdbc;
import org.apache.commons.beanutils.Converter;
/**
* EnumConverter class.
*
* @author xingwx
* @version $Id: $Id
*/
public class EnumConverter implements Converter {
/**
* {@inheritDoc}
*/
@Override
public Object convert(@SuppressWarnings("rawtypes") Class type, Object value) {
if(value==null) {
return null;
}
if(type.isEnum()) {
int v = Integer.parseInt(value.toString());
return type.getEnumConstants()[v];
}else{
System.out.println("WARN: error registed EnumConverter for type:"+type.getCanonicalName());
}
return null;
}
}