Name: rmT116609 Date: 03/02/2004
A DESCRIPTION OF THE REQUEST :
package java.util;
public class Objects {
public static boolean equals(Object o1, Object o2) {
if (o1 == null)
return o2 == null;
if (o2 == null)
return false;
return o1.equals(o2);
}
public static int hashCode(Object o) {
return (o == null) ? 0 : o.hashCode();
}
public static <T extends Comparable> int compare(T o1, T o2) {
if (o1 == null)
return o2 == null ? 0 : -1;
if (o2 == null)
return 1;
return o1.compareTo(o2);
}
}
JUSTIFICATION :
Everybody needs at least the first of the above function sooner or later.
I would bet that this Objects.equals() function is already implemented
privately in at least at 100 different places in the JDK.
Let's continue the great traditions of Collections and Arrays utility classes.
(Incident Review ID: 241124)
======================================================================
- duplicates
-
JDK-6797535 Add shared two argument static equals method to the platform
- Resolved