-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathObjectUtil.java
More file actions
73 lines (68 loc) · 1.89 KB
/
ObjectUtil.java
File metadata and controls
73 lines (68 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package cn.sinobest.ypgj.util;
import java.util.*;
/**
* 对象判断
* @author hexiaowei
*
*/
public class ObjectUtil {
/**
* 判断对象是否Empty(null或元素为0)<br>
* 实用于对如下对象做判断:String Collection及其子类 Map及其子类
*
* @param pObj
* 待检查对象
* @return boolean 返回的布尔值
*/
public static boolean isEmpty(Object pObj) {
if (pObj == null)
return true;
if (pObj == "")
return true;
if (pObj instanceof String) {
if (((String) pObj).length() == 0) {
return true;
}
} else if (pObj instanceof Collection) {
if (((Collection) pObj).size() == 0) {
return true;
}
} else if (pObj instanceof Map) {
if (((Map) pObj).size() == 0) {
return true;
}
}
return false;
}
/**
* 判断对象是否为NotEmpty(!null或元素>0)<br>
* 实用于对如下对象做判断:String Collection及其子类 Map及其子类
*
* @param pObj
* 待检查对象
* @return boolean 返回的布尔值
*/
public static boolean isNotEmpty(Object pObj) {
if (pObj == null)
return false;
if (pObj == "")
return false;
if (pObj instanceof String) {
if (((String) pObj).length() == 0) {
return false;
}
if(((String) pObj).equalsIgnoreCase("null")) {
return false;
}
} else if (pObj instanceof Collection) {
if (((Collection) pObj).size() == 0) {
return false;
}
} else if (pObj instanceof Map) {
if (((Map) pObj).size() == 0) {
return false;
}
}
return true;
}
}