package com.test;
import org.apache.commons.beanutils.BasicDynaClass;
import org.apache.commons.beanutils.DynaBean;
import org.apache.commons.beanutils.DynaProperty;
import org.apache.commons.beanutils.PropertyUtils;
public class DynProperties {
public static void main(String[] args) throws Exception, InstantiationException {
DynaProperty[] dynaProperties = new DynaProperty[]{
new DynaProperty("id",Integer.class),
new DynaProperty("name", String.class),
new DynaProperty("Gender", Enum.class)
};
BasicDynaClass basicDynaClass = new BasicDynaClass("user", null,dynaProperties);
DynaBean user = basicDynaClass.newInstance();
user.set("id",1);
user.set("name", "zhangsan");
user.set("Gender",Gender.FEMALE );
System.out.println(PropertyUtils.getSimpleProperty(user, "Gender"));
}
}