ICU-6824 Merged check utilities from CLDR.
X-SVN-Rev: 26409
This commit is contained in:
parent
6a6561f8df
commit
f1ff9f053f
@ -170,13 +170,28 @@ public final class Utility {
|
|||||||
/**
|
/**
|
||||||
* Convenience utility. Does null checks on objects, then calls equals.
|
* Convenience utility. Does null checks on objects, then calls equals.
|
||||||
*/
|
*/
|
||||||
public final static boolean objectEquals(Object source, Object target) {
|
public final static boolean objectEquals(Object a, Object b) {
|
||||||
if (source == null)
|
return a == null ?
|
||||||
return (target == null);
|
b == null ? true : false :
|
||||||
else
|
b == null ? false : a.equals(b);
|
||||||
return source.equals(target);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The ESCAPE character is used during run-length encoding. It signals
|
* The ESCAPE character is used during run-length encoding. It signals
|
||||||
* a run of identical chars.
|
* a run of identical chars.
|
||||||
|
Loading…
Reference in New Issue
Block a user