-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmptyUtils.java
More file actions
55 lines (51 loc) · 1.32 KB
/
Copy pathEmptyUtils.java
File metadata and controls
55 lines (51 loc) · 1.32 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
package ericzz.utils;
import java.util.Collection;
import java.util.Map;
/**
* 判断为空 工具类
*
* @author zhangfei
*/
public class EmptyUtils {
//判空
public static boolean isEmpty(Object obj) {
if (obj == null) {
return true;
}
if (obj instanceof CharSequence) {
return ((CharSequence) obj).length() == 0;
}
if (obj instanceof Collection) {
return ((Collection) obj).isEmpty();
}
if (obj instanceof Map) {
return ((Map) obj).isEmpty();
}
if (obj instanceof Object[]) {
Object[] object = (Object[]) obj;
if (object.length == 0) {
return true;
}
boolean empty = true;
for (int i = 0; i < object.length; i++) {
if (!isEmpty(object[i])) {
empty = false;
break;
}
}
return empty;
}
return false;
}
public static boolean isNotEmpty(Object obj) {
return !isEmpty(obj);
}
private boolean validPropertyEmpty(Object... args) {
for (int i = 0; i < args.length; i++) {
if (EmptyUtils.isEmpty(args[i])) {
return true;
}
}
return false;
}
}