|
@@ -9,51 +9,49 @@ public class ZenUtils {
|
9
|
9
|
// ###############
|
10
|
10
|
// ### Compare ###
|
11
|
11
|
// ###############
|
12
|
|
-
|
13
|
|
- //TODO how to compare them?
|
14
|
|
- public static boolean compare(Object a, Object b, String compareType) {
|
15
|
|
- CompareType type = CompareType.valueOf(compareType);
|
|
12
|
+ public static boolean compare(Object a, Object b, CompareType type) {
|
16
|
13
|
if (type == CompareType.SAME || type == CompareType.NOTSAME) {
|
17
|
14
|
final boolean same = a == b;
|
18
|
15
|
return (type == CompareType.SAME) == same;
|
19
|
16
|
}
|
20
|
17
|
|
|
18
|
+ //TODO how to compare them?
|
21
|
19
|
if (a instanceof Comparable)
|
22
|
20
|
return checkCompareReturn(((Comparable) a).compareTo(b), type);
|
23
|
21
|
return false;
|
24
|
22
|
}
|
25
|
23
|
|
26
|
24
|
|
27
|
|
- public static boolean compare(boolean a, boolean b, String compareType) {
|
28
|
|
- return checkCompareReturn(Boolean.compare(a, b), CompareType.valueOf(compareType));
|
|
25
|
+ public static boolean compare(boolean a, boolean b, CompareType compareType) {
|
|
26
|
+ return checkCompareReturn(Boolean.compare(a, b), compareType);
|
29
|
27
|
}
|
30
|
28
|
|
31
|
|
- public static boolean compare(int a, int b, String compareType) {
|
32
|
|
- return checkCompareReturn(Integer.compare(a, b), CompareType.valueOf(compareType));
|
|
29
|
+ public static boolean compare(int a, int b, CompareType compareType) {
|
|
30
|
+ return checkCompareReturn(Integer.compare(a, b), compareType);
|
33
|
31
|
}
|
34
|
32
|
|
35
|
|
- public static boolean compare(char a, char b, String compareType) {
|
36
|
|
- return checkCompareReturn(Character.compare(a, b), CompareType.valueOf(compareType));
|
|
33
|
+ public static boolean compare(char a, char b, CompareType compareType) {
|
|
34
|
+ return checkCompareReturn(Character.compare(a, b), compareType);
|
37
|
35
|
}
|
38
|
36
|
|
39
|
|
- public static boolean compare(byte a, byte b, String compareType) {
|
40
|
|
- return checkCompareReturn(Byte.compare(a, b), CompareType.valueOf(compareType));
|
|
37
|
+ public static boolean compare(byte a, byte b, CompareType compareType) {
|
|
38
|
+ return checkCompareReturn(Byte.compare(a, b), compareType);
|
41
|
39
|
}
|
42
|
40
|
|
43
|
|
- public static boolean compare(short a, short b, String compareType) {
|
44
|
|
- return checkCompareReturn(Short.compare(a, b), CompareType.valueOf(compareType));
|
|
41
|
+ public static boolean compare(short a, short b, CompareType compareType) {
|
|
42
|
+ return checkCompareReturn(Short.compare(a, b), compareType);
|
45
|
43
|
}
|
46
|
44
|
|
47
|
|
- public static boolean compare(long a, long b, String compareType) {
|
48
|
|
- return checkCompareReturn(Long.compare(a, b), CompareType.valueOf(compareType));
|
|
45
|
+ public static boolean compare(long a, long b, CompareType compareType) {
|
|
46
|
+ return checkCompareReturn(Long.compare(a, b), compareType);
|
49
|
47
|
}
|
50
|
48
|
|
51
|
|
- public static boolean compare(float a, float b, String compareType) {
|
52
|
|
- return checkCompareReturn(Float.compare(a, b), CompareType.valueOf(compareType));
|
|
49
|
+ public static boolean compare(float a, float b, CompareType compareType) {
|
|
50
|
+ return checkCompareReturn(Float.compare(a, b), compareType);
|
53
|
51
|
}
|
54
|
52
|
|
55
|
|
- public static boolean compare(double a, double b, String compareType) {
|
56
|
|
- return checkCompareReturn(Double.compare(a, b), CompareType.valueOf(compareType));
|
|
53
|
+ public static boolean compare(double a, double b, CompareType compareType) {
|
|
54
|
+ return checkCompareReturn(Double.compare(a, b), compareType);
|
57
|
55
|
}
|
58
|
56
|
|
59
|
57
|
private static boolean checkCompareReturn(int compareResult, CompareType type) {
|