01: package fri.util;
02:
03: /**
04: * Object utility. Equality and hash code for objects that may be null.
05:
06: @author Ritzberger Fritz
07: */
08:
09: public abstract class Equals {
10: /**
11: * Returns false if objects are not equal or one of them is null and the other not.
12: */
13: public static boolean equals(Object o1, Object o2) {
14: return o1 == o2 ? true : o1 == null || o2 == null ? false : o1
15: .equals(o2);
16: } // null == null is true in Java
17:
18: /**
19: * Returns zero for a null object, else the objects hash code.
20: */
21: public static int hashCode(Object o) {
22: return o == null ? 0 : o.hashCode();
23: }
24:
25: private Equals() {
26: }
27:
28: }
|