自定義判斷內(nèi)容
public class CheckNOtNullUtils {
/**
* 判斷一個對象中的某些字段是否為空
*
* @param obj 傳入一個對象
* @return 當(dāng)判斷出有為空的字段時
* @throws IllegalAccessException
*/
public static boolean checkNotNull(Object obj) throws IllegalAccessException {
Class aClass = obj.getClass();
Field[] fs = aClass.getDeclaredFields();
for (Field f : fs) {
// 設(shè)置些屬性是可以訪問的
f.setAccessible(true);
if ((f != null) && (!"".equals(f))) {
//設(shè)置權(quán)限
f.setAccessible(true);
Object o = f.get(obj);
String fieldName = f.getName();
if (fieldName.endsWith("Remark")) {
if (!(o == null || "".equals(((String) o).trim()))) {
return false;
}
}
}
}
return true;
}
}
```