オブジェクトが各フィールドに空であるかどうかを検出する方法

412 ワード

public static Boolean checkObjectIsNotNull(Object m) throws IllegalArgumentException, IllegalAccessException{
	 Boolean result = false;
	 if(m != null){
		 Class clazz = m.getClass();
		 Field[] f = clazz.getDeclaredFields();
		 for (int i = 0; i < f.length; i++) {
			 if(f[i].get(m)!=null){
				 result = true;
			 }
		  }
	 }
	 return result;
 }
 基本的なデータ型とString Dateなどはこの方法では使えません