package ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
/**
* yangzhiwei
* 使用反射给实体类k赋值(默认值)
* insert update会报null异常,为空时不能插入和更新
*/
public class ObjInvoke {
public static Object getObjDefault(Object obj) {
// 得到类对象
Class objCla = ();
Field[] fs = ();
for (int i = 0; i < ; i++) {
Field f = fs[i];
// 设置些属性是可以访问的
boolean isStatic = (());
if(isStatic){
continue;
}
// 设置些属性是可以访问的
(true);
try {
// 得到此属性的值
Object val = (obj);
// 得到此属性的类型
String type = ().toString();
if (("String") && val == null) {
// 给属性设值
(obj, "");
} else if ((("int") || ("Integer") || ("double")) && val == null) {
(obj, 0);
}else if ((("long")|| ("Long") )&& val == null){
(obj, 0L);
} else if (("Date") && val == null) {
(obj, ("1970-01-01"));
}else if(("Timestamp") && val == null){
(obj, ("1970-01-01 00:00:00"));
} else if (("BigDecimal") && val == null) {
(obj, new BigDecimal(0));
}
} catch (Exception e) {
();
}
}
return obj;
}
public static List getObjDefaultList(List objList) {
List list=new ArrayList();
for(Object t:objList){
(getObjDefault(t));
}
return list;
}
}