Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-5006670

RFE: Please provide java.util.Objects utility class

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P4 P4
    • 7
    • 5.0
    • core-libs
    • sparc
    • solaris_9



      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)
      ======================================================================

            Unassigned Unassigned
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: