| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
package com.atlassian.core.util; |
| 10 |
|
|
| 11 |
|
import org.apache.commons.collections.Predicate; |
| 12 |
|
|
| 13 |
|
import java.lang.reflect.Method; |
| 14 |
|
|
| 15 |
|
|
| 16 |
|
@link |
| 17 |
|
|
|
|
|
| 48% |
Uncovered Elements: 13 (25) |
Complexity: 14 |
Complexity Density: 1 |
|
| 18 |
|
public class ObjectUtils |
| 19 |
|
{ |
| 20 |
|
private static final Predicate NOT_EMPTY_PREDICATE = new Predicate() |
| 21 |
|
{ |
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 22 |
0
|
public boolean evaluate(Object o)... |
| 23 |
|
{ |
| 24 |
0
|
return isNotEmpty(o); |
| 25 |
|
} |
| 26 |
|
}; |
| 27 |
|
|
| 28 |
|
protected static Method hibernateGetClassMethod = null; |
| 29 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 30 |
1
|
static... |
| 31 |
|
{ |
| 32 |
1
|
try |
| 33 |
|
{ |
| 34 |
1
|
Class hibernateClass = ClassLoaderUtils.loadClass("net.sf.hibernate.Hibernate", ObjectUtils.class); |
| 35 |
1
|
hibernateGetClassMethod = hibernateClass.getMethod("getClass", new Class[]{Object.class}); |
| 36 |
|
} |
| 37 |
|
catch (Exception e) |
| 38 |
|
{ |
| 39 |
|
} |
| 40 |
|
} |
| 41 |
|
|
| 42 |
|
|
| 43 |
|
|
| 44 |
|
@return |
| 45 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 46 |
6
|
public static boolean isIdentical(Object a, Object b)... |
| 47 |
|
{ |
| 48 |
6
|
return !isDifferent(a, b); |
| 49 |
|
} |
| 50 |
|
|
| 51 |
|
|
| 52 |
|
@return |
| 53 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 5 |
Complexity Density: 1.67 |
|
| 54 |
12
|
public static boolean isDifferent(Object a, Object b)... |
| 55 |
|
{ |
| 56 |
12
|
if ((a == null && b == null) || (a != null && a.equals(b))) |
| 57 |
|
{ |
| 58 |
4
|
return false; |
| 59 |
|
} |
| 60 |
|
|
| 61 |
8
|
return true; |
| 62 |
|
} |
| 63 |
|
|
| 64 |
|
|
| 65 |
|
@link |
| 66 |
|
@param |
| 67 |
|
@return |
| 68 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 69 |
0
|
public static boolean isNotEmpty(Object o)... |
| 70 |
|
{ |
| 71 |
0
|
return o != null && !"".equals(o); |
| 72 |
|
} |
| 73 |
|
|
| 74 |
|
|
| 75 |
|
@link |
| 76 |
|
@return |
| 77 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 78 |
0
|
public static Predicate getIsSetPredicate()... |
| 79 |
|
{ |
| 80 |
0
|
return NOT_EMPTY_PREDICATE; |
| 81 |
|
} |
| 82 |
|
|
| 83 |
|
|
| 84 |
|
|
| 85 |
|
|
| 86 |
|
|
| 87 |
|
@param |
| 88 |
|
@return |
| 89 |
|
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 3 |
Complexity Density: 0.75 |
|
| 90 |
0
|
public static Class getTrueClass(Object o)... |
| 91 |
|
{ |
| 92 |
0
|
if (hibernateGetClassMethod != null) |
| 93 |
|
{ |
| 94 |
0
|
try |
| 95 |
|
{ |
| 96 |
0
|
return (Class)hibernateGetClassMethod.invoke(null, new Object[] {o}); |
| 97 |
|
} |
| 98 |
|
catch (Exception e) |
| 99 |
|
{ |
| 100 |
|
} |
| 101 |
|
} |
| 102 |
|
|
| 103 |
0
|
return o.getClass(); |
| 104 |
|
} |
| 105 |
|
} |