private SpEquipment getSpEquipment(SpEquipment spEquipment,String name, String o) {
Field field = null;
try {
if(name.indexOf("_")!=-1){
String[] s = name.split("_");
name=s[0];
for (int i = 1; i < s.length; i++) {
String first = s[i].substring(0, 1);
String after = s[i].substring(1);
first = first.toUpperCase();
after = after.toLowerCase();
s[i]=first+after;
name+=s[i];
}
}
System.out.println(name);
field = spEquipment.getClass().getDeclaredField(name);
field.setAccessible(true);
Type type = field.getGenericType();
if ("class java.lang.String".equals(type.toString())) {
field.set(spEquipment,o);
} else if ("class java.lang.Integer".equals(type.toString())) {
if(!"".equals(o)&&null!=o) {
field.set(spEquipment, Integer.parseInt(o));
}
} else if ("class java.lang.Boolean".equals(type.toString())) {
if(o.equals("on")){
o="1";
}
if(o.equals("off")){
o="0";
}
field.set(spEquipment,"1".equals(o)?true:false);
}else if ("class java.lang.Double".equals(type.toString())) {
field.set(spEquipment,Double.parseDouble(o));
}else if ("class java.lang.Float".equals(type.toString())) {
field.set(spEquipment,Float.parseFloat(o));
}
} catch (Exception e) {
e.printStackTrace();
}
return spEquipment;
}