您的位置:首页 > 其它

验证对象中属性是否为null

2013-02-25 14:11 162 查看
import java.lang.reflect.Field;

方法如下:

/**

  * 验证对象中属性是否为null

  *

  * @param vo

  * @return

  * @throws ServiceException

  */

 protected boolean checkParamOfObj(AbstractVO vo) throws ServiceException,

   IllegalArgumentException, IllegalAccessException {

  log.info("服务层操作:验证对象中属性是否为null 方法checkParamOfObj(AbstractVO ["+ vo +"])");

  Field[] field1 = vo.getClass().getDeclaredFields();

  Boolean bool = false;

  for (int i = 0; i < field1.length; i++) {

   field1[i].setAccessible(true);

   if (field1[i].get(vo) != null) {

    bool = true;

   }

  }

  return bool;

 }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: