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

RFE: Please add 'public static Boolean Boolean.getBoolean(boolean b)'

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.4.0
    • core-libs
    • x86
    • windows_nt



      Name: rmT116609 Date: 03/07/2002


      FULL PRODUCT VERSION :
      java version "1.4.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
      Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)


      A DESCRIPTION OF THE PROBLEM :
      It would be nice to add the following convienience method to Boolean.

      public static Boolean getBoolean(boolean b) {
        return (b ? Boolean.TRUE : Boolean.FALSE);
      }

      While not a significant piece of code, this would clean up a lot of places where this same logic happens today. Even better it would encourage people to use the TRUE and FALSE constants rather than just creating new Booleans as they
      often do today.

      This bug can be reproduced always.

      CUSTOMER WORKAROUND :
      Currently people do one of two things

      public void foo(boolean b) {
        Boolean b1 = new Boolean(b);
      }

      public void bar(boolean b) {
        Boolean b1 = (b ? Boolean.TRUE : Boolean.FALSE);
      }

      If this RFE is implemented they could instead do:

      public void baz(boolean b) {
        Boolean b1 = Boolean.getBoolean(b);
      }

      Which has the cleanliness of foo(), but function of bar().
      (Review ID: 143890)
      ======================================================================

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: