避免实体类空指针异常,并赋初值 可扩展


import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;


import com.upward.hbnx.model.EChannel;


/**
 * 
 * @author xiaoyang 避免空指针
 * 避免实体类会报空指针的属性get方法,为其赋值
 * 
 */


public class InitBeanUtil {


private static InitBeanUtil init = null;
private final String START_SET = "set";
private final String START_GET = "get";
private final String START_IS = "is";
private final int START_THREE = 3; // "set"字符串长度 3


// 参数初始值---begin
private final String INIT_STRING = "";
private final int INIT_INT = 0;
private final double INIT_DOUBLE = 0.0;
private final float INIT_FLOAT = 0;
private final boolean INIT_BOOLEAN = true;
private final char INIT_CHAR = ' ';


private final BigDecimal INIT_BigDecimal = new BigDecimal("0.0");
private final Integer INIT_Integer = new Integer(0);
private final Double INIT_Double = new Double(0.0);
private final Float INIT_Float = new Float(0.0);
private final Boolean INIT_Boolean = new Boolean(true);
private final Character INIT_Character = new Character(' ');
private final java.sql.Date INIT_DateS = new java.sql.Date(
System.currentTimeMillis());
private final java.util.Date INIT_DateU = new java.util.Date(
System.currentTimeMillis());
private final java.sql.Timestamp INIT_Timestamp = new java.sql.Timestamp(
System.currentTimeMillis());
private final long INIT_Long = new Long(0);
@SuppressWarnings("rawtypes")
private final java.util.List INIT_List = new ArrayList();
// 参数初始值---end


// 参数类型---begin 封装类型给出完整名
private final String TYPE_String = "java.lang.String";
private final String TYPE_int = "int";
private final String TYPE_double = "double";
private final String TYPE_float = "float";
private final String TYPE_boolean = "boolean";
private final String TYPE_char = "char";
private final String TYPE_long = "long";
private final String TYPE_BigDecimal = "java.math.BigDecimal";
private final String TYPE_Integer = "java.lang.Integer";
private final String TYPE_Double = "java.lang.Double";
private final String TYPE_Float = "java.lang.Float";
private final String TYPE_Boolean = "java.lang.Boolean";
private final String TYPE_Character = "java.lang.Character";
private final String TYPE_DateS = "java.sql.Date";
private final String TYPE_DateU = "java.util.Date";
private final String TYPE_Timestamp = "java.sql.Timestamp";
private final String TYPE_List = "java.util.List";
// 参数类型---end
}
下载地址: http://download.csdn.net/detail/op_xiaoyang/6619893

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值