ICU-6824 Merged check utilities from CLDR.
X-SVN-Rev: 26409
This commit is contained in:
parent
6a6561f8df
commit
f1ff9f053f
@ -170,11 +170,26 @@ public final class Utility {
|
||||
/**
|
||||
* Convenience utility. Does null checks on objects, then calls equals.
|
||||
*/
|
||||
public final static boolean objectEquals(Object source, Object target) {
|
||||
if (source == null)
|
||||
return (target == null);
|
||||
else
|
||||
return source.equals(target);
|
||||
public final static boolean objectEquals(Object a, Object b) {
|
||||
return a == null ?
|
||||
b == null ? true : false :
|
||||
b == null ? false : a.equals(b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience utility. Does null checks on objects, then calls compare.
|
||||
*/
|
||||
public static <T> int checkCompare(Comparable a, Comparable b) {
|
||||
return a == null ?
|
||||
b == null ? 0 : -1 :
|
||||
b == null ? 1 : a.compareTo(b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience utility. Does null checks on object, then calls hashCode.
|
||||
*/
|
||||
public static int checkHash(Object a) {
|
||||
return a == null ? 0 : a.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user